/ V 0.9 V V Page 2 of 101

Size: px
Start display at page:

Download "/ V 0.9 V 1.0 2001-7-1 2001-7-18 2001-7-18 2001-7-24 V 0.9 2001 Page 2 of 101"

Transcription

1 C++/C [ ] 1.0 [ ] [ ]

2 / V 0.9 V V Page 2 of 101

3 WINDOWS UNIX IF FOR SWITCH GOTO CONST #DEFINE Page 3 of 101

4 FREE DELETE MALLOC/FREE NEW/DELETE MALLOC/FREE NEW/DELETE C STRING STRING Page 4 of 101

5 CONST A C++/C...8 B C++/C...8 C C++/C Page 5 of 101

6 C++/C N-1 Internet (1) (2) (3) (4) (5) (6) (7) (8) (9) 30 (10) 9:00 5:00 9:00 C++/C CAD 3D 2001 Page 6 of 101

7 C++ 3D 3D strcpy IT IT 2001 Page 7 of 101

8 if 14 C++/C IT Page 8 of 101

9 B C++/C C++/C 4 C++/C Bug CMMI CMMI 2001 Page 9 of 101

10 C++/C CMMI Page 10 of 101

11 1 C++/C declaration implementation definition C++/C.h C.c C++.cpp.cc.cxx / 4 /* * Copyright (c) 2001, * All rights reserved. * * filename.h * * * * 1.1 * * * * 1.0 * * */ Page 11 of 101

12 graphics.h ifndef/define/endif #include <filename.h> #include filename.h C extern int value // 1-1 #ifndef #define GRAPHICS_H // graphics.h GRAPHICS_H #include <math.h> // #include myheader.h // void Function1( ); // class Box // ; #endif 1-2 C++/C 2001 Page 12 of 101

13 graphics.cpp 1-3 // 1-1 #include graphics.h // // void Function1( ) // void Box::Draw( ) 1-3 C++/C 1.4 Basic Fortran C++/C Page 13 of 101

14 1.5 include source 2001 Page 14 of 101

15 a b // void Function1( ) // void Function2( ) // void Function3( ) // while (condition) statement1; // if (condition) statement2; else statement3; // statement4; 2-1(a) 2-1(b) 2001 Page 15 of 101

16 if for while do 2-2 a 2-2 b int width; // int height; // int depth; // x = a + b; y = c + d; z = e + f; if (width < height) dosomething(); for (initialization; condition; update) dosomething(); // other(); int width, height, depth; // X a + b; y = c + d; z = e + f; if (width < height) dosomething(); for (initialization; condition; update) dosomething(); other(); 2-2(a) 2-2(b) int width = 10; // width int height = 10; // height int depth = 10; // depth 2001 Page 16 of 101

17 const virtual inline case if for while ; Function(x, y, z) ; for (initialization; condition; update) = +=>= <= + * % && <<, ^ 2-3-6! ~ & > for if for (i=0; i<10; i++) if ((a<=b) && (c<=d)) void Func1(int x, int y, int z); void Func1 (int x,int y,int z); if (year >= 2000) if(year>=2000) if ((a>=b) && (c<=d)) if(a>=b&&c<=d) for (i=0; i<10; i++) for(i=0;i<10;i++) for (i = 0; I < 10; i ++) x = a < b? a : b; x=a<b?a:b; int *x = &y; int * x = & y; array[5] = 0; a.function(); b->function(); // // // // // // // // // // // // // // array [ 5 ] = 0; // a. Function(); // b -> Function(); Page 17 of 101

18 a 2-4 b void Function(int x) // program code if (condition) // program code else // program code for (initialization; condition; update) // program code While (condition) // program code void Function(int x) // program code if (condition) // program code else // program code for (initialization; condition; update) // program code while (condition) // program code 2-4(a) 2-4(b) 2001 Page 18 of 101

19 if ((very_longer_variable1 >= very_longer_variable12) && (very_longer_variable3 <= very_longer_variable14) && (very_longer_variable5 <= very_longer_variable16)) dosomething(); virtual CMatrix CMultiplyMatrix (CMatrix leftmatrix, CMatrix rightmatrix); for (very_longer_initialization; very_longer_condition; very_longer_update) dosomething(); * * int* x; x int int* x, y; y x y * char *name; int *x, y; // y 2001 Page 19 of 101

20 2.7 C /* */C++ /* */ // i++; // i /* * * * * */ void Function(float x, float y, float z) if ( ) while ( ) // end of while // end of if Page 20 of 101

21 2.8 public protected private 1 private public 8-3 a 2 public private 8.3 b C++ Biarne Stroustrup class A private: int i, j; float x, y; public: void Func1(void); void Func2(void); class A public: void Func1(void); void Func2(void); private: int i, j; float x, y; 8.3(a) 8.3(b) 2001 Page 21 of 101

22 3 Microsoft ch p ppch int i, j, k; float x, y, z; int ii, ij, ik; // i int float fx, fy, fz; // f float CurrentValue NowValue min-length && max-information ANSI C 6 C++/C! maxval maxvalueuntiloverflow i,j,k,m,n,x,y,z Windows AddChild Unix add_child 2001 Page 22 of 101

23 3-1-4 int x, X; // x X void foo(int x); // foo FOO void FOO(float x); float value; float oldvalue; float newvalue; DrawBox(); // box->draw(); // int minvalue; int maxvalue; int SetValue( ); int GetValue( ); Value1,Value2 3.2 Windows Windows 2001 Page 23 of 101

24 3-2-1 class Node; // class LeafNode; // void Draw(void); // void SetValue(int value); // BOOL flag; int drawmode; const int MAX = 100; const int MAX_LENGTH = 100; s_ static void Init( ) static int s_initvalue; // g_ global int g_howmanypeople; // int g_howmuchmoney; // m_ member void Object::SetValue(int width, int height) m_width = width; m_height = height; 2001 Page 24 of 101

25 3-2-7 OpenGL gl GL 3.3 Unix 2001 Page 25 of 101

26 4 if for while goto switch C++/C 4.1 C++/C * ( ) [ ] ->.! ~ sizeof + - * & * / % + - << >> < <= > >= ==!= & ^ &&?: = += -= *= /= %= &= ^= = <<= >>= word = (high << 8) low 2001 Page 26 of 101

27 if ((a b) && (a & c)) 4.2 a = b = c = i = a >= b && c < d && c + f <= g + h ; // d = (a = b + c) + r ; a d a = b + c; d = a + r; if (a < b < c) // a < b < c if ((a<b) && (b<c)) if ( (a<b)<c ) 4.3 if if C++/C if TRUE FALSE 1 0 FALSE TRUETRUE Visual C++ TRUE 1 Visual Basic TRUE -1 flag if if (flag) // flag 2001 Page 27 of 101

28 if (!flag) // flag if (flag == TRUE) if (flag == 1 ) if (flag == FALSE) if (flag == 0) == = 0 value if if (value == 0) if (value!= 0) if (value) // value if (!value) == = float double == = >= <= x if (x == 0.0) // if ((x>=-epsinon) && (x<=epsinon)) EPSINON == = NULL NULL 0 p if if (p == NULL) // p NULL p if (p!= NULL) if (p == 0) // p if (p!= 0) if (p) if (!p) // p if 2001 Page 28 of 101

29 if (NULL == p) if (p == NULL) if (p = NULL) p NULL if (p = NULL) if (NULL = p) NULL if/else/return if (condition) return x; return y; if (condition) return x; else return y; return (condition? x : y); 4.4 C++/C for while do CPU 4-4(b) 4-4(a) for (row=0; row<100; row++) for (col=0; col<5; col++ ) for ( col=0; col<5; col++ ) for (row=0; row<100; row++) sum = sum + a[row][col]; sum = sum + a[row][col]; 4-4(a) 4-4(b) Page 29 of 101

30 4-4(c) 4-4(d) N-1 N 4-4(d) N 4-4(c) for (i=0; i<n; i++) if (condition) if (condition) for (i=0; i<n; i++) DoSomething(); DoSomething(); else DoOtherthing(); else for (i=0; i<n; i++) DoOtherthing(); 4-4(c) 4-4(d) 4.5 for for for for 4-5(a) x 0 =< x < N N 4-5(b) x 0 =< x <= N-1 N 4-5(a) for (int x=0; x<n; x++) for (int x=0; x<=n-1; x++) 4-5(a) 4-5(b) 4.6 switch if switch 2001 Page 30 of 101

31 switch if if switch switch switch (variable) case value1 : break; case value2 : break; default : break; case break default default default : break; default 4.7 goto goto goto goto goto state; String s1, s2; // goto int sum = 0; // goto state: goto C++/C goto goto goto break ; goto error; 2001 Page 31 of 101

32 error: goto 2001 Page 32 of 101

33 5 C #define C++ #define const const #define MAX 100 /* C */ const int MAX = 100; // C++ const const float PI = ; // C++ const 5.2 const #define C++ const #define 1 const 2 const C++ const const Page 33 of 101

34 5-3-2 const float RADIUS = 100; const float DIAMETER = RADIUS * 2; 5.4 #define const const const const const SIZE class A const int SIZE = 100; // const int array[size]; // SIZE ; const class A A(int size); // const int SIZE ; ; A::A(int size) : SIZE(size) // A a(100); // a SIZE 100 A b(200); // b SIZE 200 const class A enum SIZE1 = 100, SIZE2 = 200; // 2001 Page 34 of 101

35 ; int array1[size1]; int array2[size2]; PI= Page 35 of 101

36 6 C++/C C pass by value pass by pointerc++ pass by reference void void SetValue(int width, int height); // void SetValue(int, int); // float GetValue(void); // float GetValue(); // StringCopy str1 str2 void StringCopy(char *str1, char *str2); str1 str2 strsource strdestination strsource strdestination void StringCopy(char *strsource, char *strdestination); char str[20]; StringCopy(str, Hello World ); // const 2001 Page 36 of 101

37 void StringCopy(char *strdestination const char *strsource); const & C printf int printf(const chat *format[, argument] ); C void C++ C C++/ C void C getchar char c; c = getchar(); if (c == EOF) getchar c char getchar char int int getchar(void); c char [ ] EOF char if getchar return C getchar int 2001 Page 37 of 101

38 getchar getchar EOF 1 getchar int return getchar BOOL GetChar(char *c); gechar GetChar putchar(getchar()); getchar strcpy char *strcpy(char *strdest const char *strsrc); strcpy strsrc strdest strdest char str[20]; int length = strlen( strcpy(str, Hello World ) ); class String // String & operate=(const String &other); // friend friend String operate+( const String &s1, const String &s2); private: char *m_data; String operate = String & String::operate=(const String &other) if (this == &other) return *this; delete m_data; 2001 Page 38 of 101

39 m_data = new char[strlen(other.data)+1]; strcpy(m_data, other.data); return *this; // *this String return *this String a,b,c; a = b; // *this a = b = c; // *this String operate + String operate+(const String &s1, const String &s2) String temp; delete temp.data; // temp.data 0 temp.data = new char[strlen(s1.data) + strlen(s2.data) +1]; strcpy(temp.data, s1.data); strcat(temp.data, s2.data); return temp; String temp temp c = a + b; a + b c assert Page 39 of 101

40 6-3-2 return return return return 1 return char * Func(void) char str[] = hello world ; // str return str; // 2 3 return return String(s1 + s2); temp String temp(s1 + s2); return temp; temp temp temp return int(x + y); // int temp = x + y; return temp; int,float,double Page 40 of 101

41 C/C++ static static Debug Release Debug Release assert Debug 6-5 assert assert void *memcpy(void *pvto, const void *pvfrom, size_t size) assert((pvto!= NULL) && (pvfrom!= NULL)); // byte *pbto = (byte *) pvto; // pvto byte *pbfrom = (byte *) pvfrom; // pvfrom while(size -- > 0 ) *pbto ++ = *pbfrom ++ ; return pvto; 6-5 assert Debug Release assert assert assert assert assert assert [Maguire, p8-p30] 2001 Page 41 of 101

42 C++ n m referencem referent int m; int &n = m; n m n m n m m n m 1 2 NULL NULL 3 k i k = j k j k 6 k i i 6 int i = 5; int j = 6; int &k = i; k = j; // k i 6; C++ Func1 x n x n, n 0 void Func1(int x) x = x + 10; 2001 Page 42 of 101

43 int n = 0; Func1(n); cout << n = << n << endl; // n = 0 Func2 x n n n 10 void Func2(int *x) (* x) = (* x) + 10; int n = 0; Func2(&n); cout << n = << n << endl; // n = 10 Func3 x n x n x n n 10 void Func3(int &x) x = x + 10; int n = 0; Func3(n); cout << n = << n << endl; // n = Page 43 of 101

44 7 Bill Gates 640K ought to be enough for everybody Bill Gates static 2 3 malloc new free delete 7.2 NULL p assert(p!=null) malloc new if(p==null) if(p!=null) 2001 Page 44 of 101

45 1 1 for malloc free new/delete 1 2 return 3free delete NULL malloc new NULL NULL free delete NULL 7.3 C++/C 2001 Page 45 of 101

46 a 6 hello\0 a a[0]= X p world world\0 p[0]= X char a[] = hello ; a[0] = X ; cout << a << endl; char *p = world ; p[0] = X ; cout << p << endl; // p // a b b = a strcpy b a if(b==a) strcmp p = a a p a p a malloc p strlen(a)+1 strcpy if(p==a) strcmp // char a[] = "hello"; char b[10]; strcpy(b, a); // b = a; if(strcmp(b, a) == 0) // if (b == a) // int len = strlen(a); char *p = (char *)malloc(sizeof(char)*(len+1)); strcpy(p,a); // p = a; if(strcmp(p, a) == 0) // if (p == a) Page 46 of 101

47 7.3.3 sizeof a sizeof(a) 12 0 p a sizeof(p) 4 sizeof(p) sizeof(char*) p C++/C b a sizeof(a) sizeof(char *) char a[] = "hello world"; char *p = a; cout<< sizeof(a) << endl; // 12 cout<< sizeof(p) << endl; // a void Func(char a[100]) cout<< sizeof(a) << endl; // b Test GetMemory(str, 200) str str NULL void GetMemory(char *p, int num) p = (char *)malloc(sizeof(char) * num); void Test(void) char *str = NULL; GetMemory(str, 100); // str NULL strcpy(str, "hello"); // Page 47 of 101

48 GetMemory p _p = p _p p _p _p p GetMemory GetMemory free void GetMemory2(char **p, int num) *p = (char *)malloc(sizeof(char) * num); void Test2(void) char *str = NULL; GetMemory2(&str, 100); // &str strcpy(str, "hello"); cout<< str << endl; free(str); char *GetMemory3(int num) char *p = (char *)malloc(sizeof(char) * num); return p; void Test3(void) char *str = NULL; str = GetMemory3(100); strcpy(str, "hello"); cout<< str << endl; free(str); Page 48 of 101

49 return return char *GetString(void) char p[] = "hello world"; return p; // void Test4(void) char *str = NULL; str = GetString(); // str cout<< str << endl; return Test4 str = GetString str NULL str hello world char *GetString2(void) char *p = "hello world"; return p; void Test5(void) char *str = NULL; str = GetString2(); cout<< str << endl; return Test5 GetString2 GetString2 hello world GetString Page 49 of 101

50 7.5 free delete free delete delete 7-5 p free NULL p p NULL p p p if (p!= NULL) if p NULL char *p = (char *) malloc(100); strcpy(p, hello ); free(p); // p p if(p!= NULL) // strcpy(p, world ); // 7-5 p p void Func(void) char *p = (char *) malloc(100); // NULL 2001 Page 50 of 101

51 NULL 7.7 NULL NULL if if 1 NULL NULL char *p = NULL; char *str = (char *) malloc(100); 2 p free delete NULL p class A public: void Func(void) cout << Func of class A << endl; ; void Test(void) A *p; A a; p = &a; // a p->func(); // p Test p->func() a p a p 2001 Page 51 of 101

52 7.8 malloc/free new/delete malloc free C++/C new/delete C++ maloc/free malloc/free malloc/free C++ new delete new/delete malloc/free new/delete 7-8 class Obj public : Obj(void) cout << Initialization << endl; ~Obj(void) cout << Destroy << endl; void Initialize(void) cout << Initialization << endl; void Destroy(void) cout << Destroy << endl; ; void UseMallocFree(void) Obj *a = (obj *)malloc(sizeof(obj)); // a->initialize(); // // a->destroy(); // free(a); // void UseNewDelete(void) Obj *a = new Obj; // // delete a; // 7-8 malloc/free new/delete Obj Initialize Destroy UseMallocFree malloc/free Initialize Destroy UseNewDelete 2001 Page 52 of 101

53 malloc/free new/delete malloc/free new/delete new/delete malloc/free C++ malloc/free C++ C C malloc/free free new delete malloc new/delete malloc/free 7.9 malloc new NULL 1 NULL return void Func(void) A *a = new A; if(a == NULL) return; 2 NULL exit(1) void Func(void) A *a = new A; if(a == NULL) cout << Memory Exhausted << endl; exit(1); 3 new malloc Visual C++ _set_new_hander 2001 Page 53 of 101

54 new malloc new C exit(1) exit(1) 32 malloc new Windows 98 Visual C Window Unix Windows void main(void) float *p = NULL; while(true) p = new float[ ]; cout << eat memory << endl; if(p==null) exit(1); malloc/free malloc void * malloc(size_t size); malloc length 2001 Page 54 of 101

55 int *p = (int *) malloc(sizeof(int) * length); sizeof malloc void * malloc void * malloc int, float int float cout << sizeof(char) << endl; cout << sizeof(int) << endl; cout << sizeof(unsigned int) << endl; cout << sizeof(long) << endl; cout << sizeof(unsigned long) << endl; cout << sizeof(float) << endl; cout << sizeof(double) << endl; cout << sizeof(void *) << endl; malloc () sizeof p = malloc(sizeof(p)) free void free( void * memblock ); free malloc p free(p) p NULL free p p NULL free p 7.11 new/delete new malloc int *p1 = (int *)malloc(sizeof(int) * length); int *p2 = new int[length]; new sizeof new new class Obj public : Obj(void); // 2001 Page 55 of 101

56 Obj(int x); // void Test(void) Obj *a = new Obj; Obj *b = new Obj(1); // 1 delete a; delete b; new Obj *objects = new Obj[100]; // 100 Obj *objects = new Obj[100](1);// delete [] delete []objects; // delete objects; // delete objects[0] C++/C C 1 C Page 56 of 101

57 8 C++ C C++ overloaded inline const virtual const virtual C C++ C EatBeef,EatFish,EatChicken Eat void EatBeef( ); void EatFish( ); void EatChicken( ); // void Eat(Beef ); // void Eat(Fish ); // void Eat(Chicken ); Eat C Page 57 of 101

58 void Function(void); int Function (void); int int x = Function (); Function C++/C Function Eat _eat_beef _eat_fish _eat_chicken C++ C C void foo(int x, int y); C _foo C++ _foo_int_int C++ C C++ C extern C extern C void foo(int x, int y); // extern C #include myheader.h // C C++ foo C _foo _foo_int_int C++ C extern C include void Print( ); // class A void Print( ); // 2001 Page 58 of 101

59 Print Print :: ::Print( ); // Print output int output float output(0.5) int float # include <iostream.h> void output( int x); // void output( float x); // void output( int x) cout << " output int " << x << endl ; void output( float x) cout << " output float " << x << endl ; void main(void) int x = 1; float y = 1.0; output(x); // output int 1 output(y); // output float 1 output(1); // output int 1 // output(0.5); // error! ambiguous call, output(int(0.5)); // output int 0 output(float(0.5)); // output float Page 59 of 101

60 8.2 override C virtual virtual Base::f(int) Base::f(float) Base::g(void) Derived::g(void) #include <iostream.h> class Base public: void f(int x) cout << "Base::f(int) " << x << endl; void f(float x) cout << "Base::f(float) " << x << endl; virtual void g(void) cout << "Base::g(void)" << endl; ; class Derived : public Base public: virtual void g(void) cout << "Derived::g(void)" << endl; ; void main(void) Derived d; Base *pb = &d; pb->f(42); // Base::f(int) Page 60 of 101

61 pb->f(3.14f); // Base::f(float) 3.14 pb->g(); // Derived::g(void) C++ 1 virtual 2 virtual a 1 Derived::f(float) Base::f(float) 2 Derived::g(int) Base::g(float) 3 Derived::h(float) Base::h(float) #include <iostream.h> class Base public: virtual void f(float x) cout << "Base::f(float) " << x << endl; void g(float x) cout << "Base::g(float) " << x << endl; void h(float x) cout << "Base::h(float) " << x << endl; ; class Derived : public Base public: virtual void f(float x) cout << "Derived::f(float) " << x << endl; void g(int x) cout << "Derived::g(int) " << x << endl; void h(float x) cout << "Derived::h(float) " << x << endl; ; a C b bp dp 2001 Page 61 of 101

62 void main(void) Derived d; Base *pb = &d; Derived *pd = &d; // Good : behavior depends solely on type of the object pb->f(3.14f); // Derived::f(float) 3.14 pd->f(3.14f); // Derived::f(float) 3.14 // Bad : behavior depends on type of the pointer pb->g(3.14f); // Base::g(float) 3.14 pd->g(3.14f); // Derived::g(int) 3 (surprise!) // Bad : behavior depends on type of the pointer pb->h(3.14f); // Base::h(float) 3.14 (surprise!) pd->h(3.14f); // Derived::h(float) b pd->f(10) Base::f(int) Base::f(int) Derived::f(char *) 10 class Base public: void f(int x); ; class Derived : public Base public: void f(char *str); ; void Test(void) Derived *pd = new Derived; pd->f(10); // error Page 62 of 101

63 8-2-3 pd->f(10) Derived::f(char *) Derived f pd->f(10) f pd->f(10) Base::f(int) Derived class Derived : public Base public: void f(char *str); void f(int x) Base::f(x); ; 8.3 C void Foo(int x=0, int y=0); // void Foo(int x=0, int y=0) // void Foo(int x, int y=0, int z=0); 2001 Page 63 of 101

64 void Foo(int x=0, int y, int z=0); output #include <iostream.h> void output( int x); void output( int x, float y=0.0); void output( int x) cout << " output int " << x << endl ; void output( int x, float y) cout << " output int " << x << " and float " << y << endl ; void main(void) int x=1; float y=0.5; // output(x); // error! ambiguous call output(x,y); // output int 1 and float C++ operator Complex Add(const Complex &a, const Complex &b); 2001 Page 64 of 101

65 Complex operator +(const Complex &a, const Complex &b); Complex a, b, c; c = Add(a, b); // c = a + b; // + [Murray, p44-p47] = () [] -> += -= /= *= &= = ~= %= >>= <<= C++ C C++ 1 C++ int,float C++ #,@,$ Page 65 of 101

66 C++ C CALL return #define MAX(a, b) (a) > (b)? (a) : (b) result = MAX(i, j) + 2 ; result = (i) > (j)? (i) : (j) + 2 ; + : result = ( (i) > (j)? (i) : (j) ) + 2 ; #define MAX(a, b) ( (a) > (b)? (a) : (b) ) result = MAX(i++, j); result = (i++) > (j)? (i++) : (j); C++ C++ this C++ C++ assert assert Debug Debug Release assert assert Debug Release assert inline inline Foo inline void Foo(int x, int y); // inline 2001 Page 66 of 101

67 void Foo(int x, int y) Foo void Foo(int x, int y); inline void Foo(int x, int y) // inline inline inline inline C++/C class A public: void Foo(int x, int y) // // class A public: void Foo(int x, int y) // inline void A::Foo(int x, int y) Page 67 of 101

68 1 2 inline 8.6 C++ C Page 68 of 101

69 9 A C++ A A(void); // A(const A &a); // ~A(void); // A & operate =(const A &a);// 1 C++ Stroustrup 2 C++ String String class String public: String(const char *str = NULL); // String(const String &other); // ~ String(void); // String & operate =(const String &other); // private: char *m_data; // ; 9.1 C C Page 69 of 101

70 Stroustrup C++ Stroustrup ~ void [Eekel, p55-p56] 9.2 class A A(int x); // A ; class B : public A B(int x, int y);// B ; B::B(int x, int y) : A(x) // A const Page 70 of 101

71 class A A(void); // A(const A &other); // A & operate =( const A &other); // class B public: B(const A &a); // B private: A m_a; // ; 9-2(a) B A m_a 9-2 (b) B m_a B m_a A A a m_a B::B(const A &a) B::B(const A &a) : m_a(a) m_a = a; 9-2(a) 9-2(b) F class F public: F(int x, int y); // private: int m_x, m_y; int m_i, m_j; 2001 Page 71 of 101

72 9-2(c) F 9-2(d) F F::F(int x, int y) F::F(int x, int y) : m_x(x), m_y(y) m_x = x; m_i = 0; m_y = y; m_j = 0; m_i = 0; m_j = 0; 9-2(c) 9-2(d) 9.3 [Eckel, p ] 9.4 String // String String::String(const char *str) if(str==null) m_data = new char[1]; *m_data = 0 ; else int length = strlen(str); m_data = new char[length+1]; strcpy(m_data, str); 2001 Page 72 of 101

73 // String String::~String(void) delete [] m_data; // m_data delete m_data; 9.5 String a,b a.m_data hello b.m_data world a b b.m_data = a.m_data b.m_data b.m_data a.m_data a b m_data String a( hello ); String b( world ); String c = a; // c(a); c = b; // String c(a) 9.6 String // String::String(const String &other) 2001 Page 73 of 101

74 // other m_data int length = strlen(other.m_data); m_data = new char[length+1]; strcpy(m_data, other.m_data); // String & String::operate =(const String &other) // (1) if(this == &other) return *this; // (2) delete [] m_data; // 3 int length = strlen(other.m_data); m_data = new char[length+1]; strcpy(m_data, other.m_data); // 4 return *this; String 9.4 NULL NULL String 1 a = a // b = a; c = b; a = c; // b = &a; a = *b; 2001 Page 74 of 101

75 delete if if(this == &other) if( *this == other) 2 delete 3 strlen 0 strcpy 0 4 a = b = c return *this return this return other other other return other 9.7 class A private: A(const A &a); // A & operate =(const A &a);// ; A b(a); // b = a; // A Page 75 of 101

76 virtual #include <iostream.h> class Base public: virtual ~Base() cout<< "~Base" << endl ; ; class Derived : public Base public: virtual ~Derived() cout<< "~Derived" << endl ; ; void main(void) Base * pb = new Derived; // upcast delete pb; ~Derived ~Base ~Base class Base public: Base & operate =(const Base &other); // Base private: int m_i, m_j, m_k; ; class Derived : public Base public: 2001 Page 76 of 101

77 Derived & operate =(const Derived &other); private: int m_x, m_y, m_z; ; // Derived Derived & Derived::operate =(const Derived &other) // 1 if(this == &other) return *this; // 2 Base::operate =(other); // // 3 m_x = other.m_x; m_y = other.m_y; m_z = other.m_z; // 4 return *this; 9.9 C++ Big-Three Big-Three [Cline] [Meyers] [Murry] 2001 Page 77 of 101

78 10 Object Class Instance C++ Inheritance Composition COM CORBA C++ COM CORBA 10.1 A B A B A class A public: void Func1(void); void Func2(void); ; class B : public A public: void Func3(void); void Func4(void); ; main() B b; b.func1(); b.func2(); b.func3(); b.func4(); // B A Func1 // B A Func2 C Page 78 of 101

79 A B B B A B A a kind of B A Man Human Boy Man Human Boy Man class Human ; class Man : public Human ; class Boy : public Man ; Ostrich Bird Ostrich Bird Ostrich::Fly class Bird public: virtual void Fly(void); ; class Ostrich : public Bird ; Circle Ellipse Circle Ellipse 2001 Page 79 of 101

80 B A A B B A A B a part of B A A B Eye Nose Mouth Ear Head Head Eye Nose Mouth Ear class Eye public: void Look(void); ; class Nose public: void Smell(void); ; class Mouth public: void Eat(void); ; class Ear public: void Listen(void); ; // class Head public: void Look(void) m_eye.look(); void Smell(void) m_nose.smell(); void Eat(void) m_mouth.eat(); void Listen(void) m_ear.listen(); private: Eye m_eye; Nose m_nose; Mouth m_mouth; Ear m_ear; ; Head Eye Nose Mouth Ear Head Eye Nose Mouth Ear Head Look 2001 Page 80 of 101

81 Smell Eat Listen // class Head : public Eye, public Nose, public Mouth, public Ear ; Head Eye Nose Mouth Ear 2001 Page 81 of 101

82 const const C++ const const const const constant const C++ Use const whenever you need const const const const StringCopy void StringCopy(char *strdestination, const char *strsource); strsource strdestination strsource const strsource const void Func1(int x) void Func1(const int x) void Func2(A a) void Func2(const A a) A void Func(A a) A a void Func(A &a) void Func(A &a) a const void Func(const A &a) void Func(int x) void Func(const int &x) const & Page 82 of 101

83 const void Func(A a) void Func(const A &a) const void Func(int x) void Func(const int &x) const & const const const const char * GetString(void); char *str = GetString(); const char *str = GetString(); const int GetInt(void) const int GetInt(void) A GetA(void) const A GetA(void) A A GetA(void) const A & GetA(void) 6.2 class A A & operate = (const A &other); // ; A a, b, c; // a, b, c A a = b = c; // 2001 Page 83 of 101

84 (a = b) = c; // const a = b = c (a = b) = c const const const const stack GetCount GetCount const GetCount class Stack public: void Push(int elem); int Pop(void); int GetCount(void) const; // const private: int m_num; int m_data[100]; ; int Stack::GetCount(void) const ++ m_num; // m_num Pop(); // const return m_num; const const Page 84 of 101

85 && <= >= I/O Page 85 of 101

86 PC-Lint LogiScope 2001 Page 86 of 101

87 [Cline] Marshall P. Cline and Greg A. Lomow, C++ FAQs, Addison-Wesley, 1995 [Eckel] Bruce Eckel, Thinking in C++ C [Maguire] Steve Maguire, Writing Clean Code 1993 [Meyers] Scott Meyers, Effective C++, Addison-Wesley, 1992 [Murry] Robert B. Murry, C++ Strategies and Tactics, Addison-Wesley, 1993 [Summit] Steve Summit, C Programming FAQs, Addison-Wesley, Page 87 of 101

88 A C++/C ifndef/define/endif? If for while do * public, protected, private min-length && max-information 2001 Page 88 of 101

89 if? 1 TRUE FALSE == = 3 == = NULL Case break switch default goto? C++ const const const 2001 Page 89 of 101

90 return assert assert return const const Use const whenever you need malloc new NULL 1 2 free delete NULL malloc/free new/delete malloc new/delete C Page 90 of 101

91 C *this virtual 4 1 B A A B B A 2 A B a part of B A A B 2001 Page 91 of 101

92 I/O 2001 Page 92 of 101

93 B C++/C C++/C C++/C C++/C 90 BOOL, float, if 10 0, 0.0, FALSE int n if if ( n == 0 ) if ( n!= 0 ) BOOL flag if float x if char *p if Windows NT 32 C++ sizeof 10 char str[] = Hello ; char *p = str ; int n = 10; sizeof (str ) = void Func ( char str[100]) sizeof( str ) = sizeof ( p ) = sizeof ( n ) = void *p = malloc( 100 ); sizeof ( p ) = 2001 Page 93 of 101

94 25 1 ifndef/define/endif 2 #include <filename.h> #include filename.h 3 const 4 C++ C extern C 5 for // for (i=0; i<n; i++) if (condition) DoSomething(); else DoOtherthing(); // if (condition) for (i=0; i<n; i++) DoSomething(); else for (i=0; i<n; i++) DoOtherthing(); 2001 Page 94 of 101

95 20 void GetMemory(char *p) p = (char *)malloc(100); void Test(void) char *str = NULL; GetMemory(str); strcpy(str, "hello world"); printf(str); char *GetMemory(void) char p[] = "hello world"; return p; void Test(void) char *str = NULL; str = GetMemory(); printf(str); Test Test Void GetMemory2(char **p, int num) void Test(void) *p = (char *)malloc(num); char *str = (char *) malloc(100); strcpy(str, hello ); void Test(void) free(str); if(str!= NULL) char *str = NULL; GetMemory(&str, 100); strcpy(str, world ); strcpy(str, "hello"); printf(str); printf(str); Test Test 2001 Page 95 of 101

96 strcpy 10 strcpy char *strcpy(char *strdest, const char *strsrc); strdest strsrc 1 C++/C strcpy 2 strcpy strsrc strdest char * String 25 String class String public: String(const char *str = NULL); // String(const String &other); // ~ String(void); // String & operate =(const String &other); // private: char *m_data; // ; String Page 96 of 101

97 C C++/C BOOL, float, if 10 BOOL flag if 3 if ( flag ) if (!flag ) float x if 4 if (flag == TRUE) if (flag == 1 ) if (flag == FALSE) if (flag == 0) const float EPSINON = ; if ((x >= - EPSINON) && (x <= EPSINON) if (x == 0.0) == = if (x!= 0.0) >= <= char *p if 3 if (p == NULL) if (p == 0) if (p!= NULL) if (p!= 0) if (p) if (!) Windows NT 32 C++ sizeof 10 char str[] = Hello ; char *p = str ; int n = 10; sizeof (str ) = 6 void Func ( char str[100]) sizeof( str ) = sizeof ( p ) = 4 2 void *p = malloc( 100 ); sizeof ( n ) = 4 2 sizeof ( p ) = Page 97 of 101

98 25 1 ifndef/define/endif 5 2 #include <filename.h> #include filename.h 5 #include <filename.h> filename.h #include filename.h filename.h 3 const 5 1 const 2 const const 4 C++ C extern C 5 C++ C C++ C void foo(int x, int y); C _foo C++ _foo_int_int C++ C extern C 5 for 5 for (i=0; i<n; i++) if (condition) DoSomething(); else DoOtherthing(); if (condition) for (i=0; i<n; i++) DoSomething(); else for (i=0; i<n; i++) DoOtherthing(); N Page 98 of 101

99 5 20 void GetMemory(char *p) p = (char *)malloc(100); void Test(void) char *str = NULL; GetMemory(str); strcpy(str, "hello world"); printf(str); char *GetMemory(void) char p[] = "hello world"; return p; void Test(void) char *str = NULL; str = GetMemory(); printf(str); Test Test GetMemory GetMemory Test str NULL NULL strcpy(str, "hello world"); void GetMemory2(char **p, int num) void Test(void) *p = (char *)malloc(num); char *str = (char *) malloc(100); strcpy(str, hello ); void Test(void) free(str); if(str!= NULL) char *str = NULL; GetMemory(&str, 100); strcpy(str, world ); strcpy(str, "hello"); printf(str); printf(str); Test Test 1 hello 2 free(str); if(str!= NULL) 2001 Page 99 of 101

100 strcpy 10 strcpy char *strcpy(char *strdest, const char *strsrc); strdest strsrc 1 C++/C strcpy char *strcpy(char *strdest, const char *strsrc); assert((strdest!=null) && (strsrc!=null)); // 2 char *address = strdest; // 2 while( (*strdest++ = * strsrc++)!= 0 ) // 2 NULL ; return address ; // 2 2 strcpy strsrc strdest char * // 2 int length = strlen( strcpy( strdest, hello world ) ); String 25 String class String public: String(const char *str = NULL); // String(const String &other); // ~ String(void); // String & operate =(const String &other); // private: char *m_data; // ; String 4 // String String::~String(void) // 3 delete [] m_data; // m_data delete m_data; 2001 Page 100 of 101

101 // String String::String(const char *str) // 6 if(str==null) m_data = new char[1]; // NULL *m_data = 0 ; else int length = strlen(str); m_data = new char[length+1]; // NULL strcpy(m_data, str); // String::String(const String &other) // 3 int length = strlen(other.m_data); m_data = new char[length+1]; // NULL strcpy(m_data, other.m_data); // String & String::operate =(const String &other) // 13 // (1) // 4 if(this == &other) return *this; // (2) // 3 delete [] m_data; // 3 // 3 int length = strlen(other.m_data); m_data = new char[length+1]; // NULL strcpy(m_data, other.m_data); // 4 // 3 return *this; 2001Flyincloud

为提高我们的程序品质特将林博士的资料作为我公司程序员的学习教材,请各位读读,我把我的看法用红字表出,供大家探讨

为提高我们的程序品质特将林博士的资料作为我公司程序员的学习教材,请各位读读,我把我的看法用红字表出,供大家探讨 C++/C [ ] [] 1.0 2001 7 24 [ ] / V 0.9 2001-7-1 V 1.0 2001-7-18 2001-7-18 V 0.9 2001-7-24 4 1 10 1.1 10 1.2 11 1.3 13 1.4 14 1.5 14 2 15 2.1 15 2.2 16 2.3 17 2.4 19 2.5 20 2.6 21 2.7 22 2.8 23 3 25 3.1

More information

<4D6963726F736F667420576F7264202D20B8DFD6CAC1BF432B2BB1E0B3CCD6B8C4CF2E646F63>

<4D6963726F736F667420576F7264202D20B8DFD6CAC1BF432B2BB1E0B3CCD6B8C4CF2E646F63> 高 质 量 C++/C 编 程 指 南 文 件 状 态 [ ] 草 稿 文 件 文 件 标 识 : 当 前 版 本 : 1.0 [ ] 正 式 文 件 作 者 : 林 锐 博 士 [ ] 更 改 正 式 文 件 完 成 日 期 : 2001 年 7 月 24 日 版 本 历 史 版 本 / 状 态 作 者 参 与 者 起 止 日 期 备 注 V 0.9 林 锐 2001-7-1 至 林 锐 起 草

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

Chapter12 Derived Classes

Chapter12   Derived Classes 继 承 -- 派 生 类 复 习 1. 有 下 面 类 的 说 明, 有 错 误 的 语 句 是 : class X { A) const int a; B) X(); C) X(int val) {a=2 D) ~X(); 答 案 :C 不 正 确, 应 改 成 X(int val) : a(2) { 2. 下 列 静 态 数 据 成 员 的 特 性 中, 错 误 的 是 A) 说 明 静 态 数

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

提问袁小兵:

提问袁小兵: C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 第 六 讲 指 针 与 字 符 串 1 内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 指 针 什 么 是 指 针 指 针 的 定 义 与 运 算 指 针 与 一 维 数 组 指 针 数 组 行 指 针 与 二 维 数 组 指 针 与 引 用 指 针 与 函 数 3 指 针 定 义 什 么 是 指 针 指 针 变 量, 简 称 指 针, 用 来 存 放

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

untitled

untitled 1 7 7.1 7.2 7.3 7.4 7.5 2 7.1 VFT virtual 7.1 3 1 1. 2. public protected public 3. VFT 4. this const volatile 4 2 5. ( ) ( ) 7.1 6. no-static virtual 7.2 7. inline 7.3 5 3 8. this this 9. ( ) ( ) delete

More information

02

02 Thinking in C++: Volume One: Introduction to Standard C++, Second Edition & Volume Two: Practical Programming C++ C C++ C++ 3 3 C C class C++ C++ C++ C++ string vector 2.1 interpreter compiler 2.1.1 BASIC

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

全国计算机技术与软件专业技术资格(水平)考试

全国计算机技术与软件专业技术资格(水平)考试 全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

More information

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

_汪_文前新ok[3.1].doc

_汪_文前新ok[3.1].doc 普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7 1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7-80097 - 564-9 /TP 8 : 10. 00 ,,,, 1994 NCRE,,, ( ),,,,,

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

Microsoft Word - 970617cppFinalSolution.doc

Microsoft Word - 970617cppFinalSolution.doc 國 立 台 灣 海 洋 大 學 資 訊 工 程 系 C++ 程 式 設 計 期 末 考 參 考 答 案 姓 名 : 系 級 : 學 號 : 97/06/17 考 試 時 間 :10:00 12:10 試 題 敘 述 蠻 多 的, 看 清 楚 題 目 問 什 麼, 針 對 重 點 回 答 是 很 重 要 的 ; 不 確 定 的 請 一 定 要 當 場 提 出 來, 不 要 白 花 力 氣 在 誤 會

More information

extend

extend (object oriented) Encapsulation Inheritance Polymorphism Dynamic Binding (base class) (derived class) 1 class Base { int I; void X(); void Y(); class Derived: public Base { private: int j; void z(); Derived

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

C/C++ - 字符串与字符串函数

C/C++ - 字符串与字符串函数 C/C++ Table of contents 1. 2. 3. 4. 1 char C 2 char greeting [50] = " How " " are " " you?"; char greeting [50] = " How are you?"; 3 printf ("\" Ready, go!\" exclaimed John."); " Ready, go!" exclaimed

More information

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

More information

CHAPTER VC#

CHAPTER VC# 1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8 Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2 2-1 2-1.1 2-1 1 10 10!(1 10) 2-3 Visual C# 2008 10! 32767 short( )

More information

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 C C trio@seu.edu.cn C C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 Week3 C Week5 Week5 Memory & Pointer

More information

相 应 功 能 (5) 再 将 Boy 类 作 为 Girl 类 的 友 元 类, 在 Boy 类 的 某 成 员 函 数 VisitGirl(Girl & ) 中 访 问 Girl 类 的 私 有 成 员, 观 察 编 译 器 给 出 的 信 息 ( 6 ) 删 除 两 个 类 中 的 函 数 V

相 应 功 能 (5) 再 将 Boy 类 作 为 Girl 类 的 友 元 类, 在 Boy 类 的 某 成 员 函 数 VisitGirl(Girl & ) 中 访 问 Girl 类 的 私 有 成 员, 观 察 编 译 器 给 出 的 信 息 ( 6 ) 删 除 两 个 类 中 的 函 数 V 面 向 对 象 程 序 设 计 及 C++ 课 程 实 验 教 学 大 纲 课 程 编 号 : B030001S 课 程 名 称 : 面 向 对 象 程 序 设 计 及 C++ 课 内 总 学 时 : 3 上 机 实 验 学 时 : 8 一 实 验 课 程 的 性 质 目 的 和 任 务 性 质 : 本 实 验 课 程 是 本 科 理 工 科 各 专 业 学 生 的 通 识 基 础 课, 该 实 验

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620

More information

C

C C 2017 3 14 1. 2. 3. 4. 2/95 C 1. 3/95 C I 1 // talkback.c: 2 #include 3 #include 4 #define DENSITY 62.4 5 int main(void) 6 { 7 float weight, volume; 8 int size; 9 unsigned long letters;

More information

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un Linux C July 27, 2016 Contents 1 Linux IDE 1 2 GCC 3 2.1 hello.c hello.exe........................... 5 2.2............................... 9 2.2.1 -Wall................................ 9 2.2.2 -E..................................

More information

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 範 例 試 題 (C++) 試 題 編 號 :11900-920201-4 審 定 日 期 : 94 年 7 月 1 日 修 訂 日 期 : 96 年 2 月 1 日 97 年 1 月 30 日 ( 第 二 部 份 ) 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 應 檢 參 考 資 料 壹 試

More information

Microsoft Word - 物件導向編程精要.doc

Microsoft Word - 物件導向編程精要.doc Essential Object-Oriented Programming Josh Ko 2007.03.11 object-oriented programming C++ Java OO class object OOP Ruby duck typing complexity abstraction paradigm objects objects model object-oriented

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

untitled

untitled 1 5 IBM Intel 1. IBM 第 1/175 页 第 2/175 页 第 3/175 页 80 第 4/175 页 2. IBM 第 5/175 页 3. (1) 第 6/175 页 第 7/175 页 第 8/175 页 = = 第 9/175 页 = = = = = 第 10/175 页 = = = = = = = = 3. (2) 第 11/175 页 第 12/175 页 第 13/175

More information

zt

zt !!!!!!!!!!!!!!!!!!!! $ $ $ $ $ $ $ $ $ $ % $ % (!$ $ &% ) $ $ *) $ $ $ $ $ $ +) $ $ $ $ $ $,) $ $ $ $ $ $ -) $ $ $ $ $ $!) $ $ *) $ $ $ +) $ $ $,) $ $ $ -) $ $ $ () $ $ *) $ $ $ +),) -) &) $ $ *) +),)!

More information

中 国 中 西 医 结 合 杂 志 年 月 第 卷 第 期!" 通 透 性 增 加 产 生 蛋 白 水 解 酶 促 进 血 管 内 皮 细 胞 有 丝 分 裂 内 皮 细 胞 从 基 底 膜 上 迁 移 到 血 管 周 围 间 隙 粘 附 聚 集 重 构 为 三 维 管 腔 并 与 周 围 血 管

中 国 中 西 医 结 合 杂 志 年 月 第 卷 第 期! 通 透 性 增 加 产 生 蛋 白 水 解 酶 促 进 血 管 内 皮 细 胞 有 丝 分 裂 内 皮 细 胞 从 基 底 膜 上 迁 移 到 血 管 周 围 间 隙 粘 附 聚 集 重 构 为 三 维 管 腔 并 与 周 围 血 管 中 国 中 西 医 结 合 杂 志 年 月 第 卷 第 期!" 学 术 探 讨 冠 心 病 的 治 疗 性 血 管 新 生 与 活 血 化 瘀 段 练 熊 兴 江 王 阶 摘 要 治 疗 性 血 管 新 生 /) '0 1/ * ' 是 冠 状 动 脉 硬 化 性 心 脏 病 * '( '/) *! / * ) '/ ' + 治 疗 的 新 策 略 而 活 血 化 瘀 治 法 对 于 + 的 基 础

More information

Microsoft Word - ch04三校.doc

Microsoft Word - ch04三校.doc 4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear

More information

CHAPTER 1

CHAPTER 1 CHAPTER 1 1-1 System Development Life Cycle; SDLC SDLC Waterfall Model Shelly 1995 1. Preliminary Investigation 2. System Analysis 3. System Design 4. System Development 5. System Implementation and Evaluation

More information

Strings

Strings Inheritance Cheng-Chin Chiang Relationships among Classes A 類 別 使 用 B 類 別 學 生 使 用 手 機 傳 遞 訊 息 公 司 使 用 金 庫 儲 存 重 要 文 件 人 類 使 用 交 通 工 具 旅 行 A 類 別 中 有 B 類 別 汽 車 有 輪 子 三 角 形 有 三 個 頂 點 電 腦 內 有 中 央 處 理 單 元 A

More information

四川省普通高等学校

四川省普通高等学校 四 川 省 普 通 高 等 学 校 计 算 机 应 用 知 识 和 能 力 等 级 考 试 考 试 大 纲 (2013 年 试 行 版 ) 四 川 省 教 育 厅 计 算 机 等 级 考 试 中 心 2013 年 1 月 目 录 一 级 考 试 大 纲 1 二 级 考 试 大 纲 6 程 序 设 计 公 共 基 础 知 识 6 BASIC 语 言 程 序 设 计 (Visual Basic) 9

More information

Ps22Pdf

Ps22Pdf C ( CIP) C /. :, 2001. 7 21 ISBN 7-5624 -2355-5. C........ C. TP312 CIP ( 2001 ) 034496 C * * : 7871092 1 /16 : 14. 25 : 356 20017 1 20017 1 : 1 6 000 ISBN 7-5624-2355-5 / TP311 : 21. 00 C, C,,,, C,, (

More information

ebook39-5

ebook39-5 5 3 last-in-first-out, LIFO 3-1 L i n e a r L i s t 3-8 C h a i n 3 3. 8. 3 C + + 5.1 [ ] s t a c k t o p b o t t o m 5-1a 5-1a E D 5-1b 5-1b E E 5-1a 5-1b 5-1c E t o p D t o p D C C B B B t o p A b o

More information

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344> 1. 請 問 誰 提 出 積 體 電 路 (IC) 上 可 容 納 的 電 晶 體 數 目, 約 每 隔 24 個 月 (1975 年 更 改 為 18 個 月 ) 便 會 增 加 一 倍, 效 能 也 將 提 升 一 倍, 也 揭 示 了 資 訊 科 技 進 步 的 速 度? (A) 英 特 爾 (Intel) 公 司 創 始 人 戈 登. 摩 爾 (Gordon Moore) (B) 微 軟 (Microsoft)

More information

Strings

Strings Polymorphism and Virtual Functions Cheng-Chin Chiang Virtual Function Basics 多 型 (Polymorphism) 賦 予 一 個 函 數 多 種 意 涵, 存 在 於 同 一 類 別 之 內 祖 先 類 別 與 後 代 類 別 間 物 件 導 向 程 式 設 計 基 本 原 理 虛 擬 函 數 (Virtual Function)

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc 2 5 8 11 0 1. 13 2. 15 3. 18 1 1. 22 2. 25 3. 27 2 1. 35 2. 38 3. 41 4. 43 5. 48 6. 50 3 1. 56 2. 59 3. 63 4. 65 5. 69 13 22 35 56 6. 74 7. 82 8. 84 9. 87 10. 97 11. 102 12. 107 13. 111 4 114 1. 114 2.

More information

! "#$ %$ $ 资 料 与 方 法 $ 调 查 对 象 全 国 东 北 华 北 华 东 西 北 西 南 和 中 南 六 个 大 区 个 省 自 治 区 直 辖 市 * 个 城 市 中 的 & 所 医 院 参 加 了 本 次 调 查 各 省 省 会 城 市 的 医 学 院 校 附 属 医 院 省

! #$ %$ $ 资 料 与 方 法 $ 调 查 对 象 全 国 东 北 华 北 华 东 西 北 西 南 和 中 南 六 个 大 区 个 省 自 治 区 直 辖 市 * 个 城 市 中 的 & 所 医 院 参 加 了 本 次 调 查 各 省 省 会 城 市 的 医 学 院 校 附 属 医 院 省 ! "#$ %$ $ 临 床 研 究 中 国 住 院 新 生 儿 流 行 病 学 调 查 中 华 医 学 会 儿 科 学 分 会 新 生 儿 学 组 摘 要 目 的 通 过 全 国 范 围 内 城 市 医 院 住 院 新 生 儿 的 调 查 以 了 解 我 国 目 前 住 院 新 生 儿 的 疾 病 谱 及 转 归 方 法 抽 取 全 国 个 省 和 自 治 区 的 * 个 城 市 中 的 & 所

More information

Microsoft Word - 11.doc

Microsoft Word - 11.doc 除 錯 技 巧 您 將 於 本 章 學 到 以 下 各 項 : 如 何 在 Visual C++ 2010 的 除 錯 工 具 控 制 下 執 行 程 式? 如 何 逐 步 地 執 行 程 式 的 敘 述? 如 何 監 看 或 改 變 程 式 中 的 變 數 值? 如 何 監 看 程 式 中 計 算 式 的 值? 何 謂 Call Stack? 何 謂 診 斷 器 (assertion)? 如 何

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Fortran Algol Pascal Modula-2 BCPL C Simula SmallTalk C++ Ada Java C# C Fortran 5.1 message A B 5.2 1 class Vehicle subclass Car object mycar public class Vehicle extends Object{ public int WheelNum

More information

Microsoft PowerPoint - OPVB1基本VB.ppt

Microsoft PowerPoint - OPVB1基本VB.ppt 大 綱 0.VB 能 做 什 麼? CH1 VB 基 本 認 識 1.VB 歷 史 與 版 本 2.VB 環 境 簡 介 3. 即 時 運 算 視 窗 1 0.VB 能 做 什 麼? Visual Basic =>VB=> 程 式 設 計 語 言 => 設 計 程 式 設 計 你 想 要 的 功 能 的 程 式 自 動 化 資 料 庫 計 算 模 擬 遊 戲 網 路 監 控 實 驗 輔 助 自 動

More information

C C

C C C C 2017 3 8 1. 2. 3. 4. char 5. 2/101 C 1. 3/101 C C = 5 (F 32). 9 F C 4/101 C 1 // fal2cel.c: Convert Fah temperature to Cel temperature 2 #include 3 int main(void) 4 { 5 float fah, cel; 6 printf("please

More information

C, Win-TC Turbo C,, C, C,,,, C C, : Win-TC C, 23,,, 15,, C Turbo C Win-TC Turbo C,,,, 2005 1 W in -TC 1 Win-TC 1 1. Win-TC 1 2. Win-TC 1 3. Win-TC 1 2 Win-TC 3 1. 3 2. 3 3. 4 4. 4 5. 4 6. 4 7. 5 8. 5 9.

More information

Microsoft Word - 2008年9月二级C真卷.doc

Microsoft Word - 2008年9月二级C真卷.doc 机 密 启 用 前 2008 年 9 月 全 国 计 算 机 等 级 考 试 二 级 笔 试 试 卷 C 语 言 程 序 设 计 24 注 意 事 项 一 考 生 应 严 格 遵 守 考 场 规 则, 得 到 监 考 人 员 指 令 后 方 可 作 答 二 考 生 拿 到 试 卷 后 应 首 先 将 自 己 的 姓 名 准 考 证 号 等 内 容 涂 写 在 答 题 卡 的 相 应 位 置 上 三

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

第5章修改稿

第5章修改稿 (Programming Language), ok,, if then else,(), ()() 5.0 5.0.0, (Variable Declaration) var x : T x, T, x,,,, var x : T P = x, x' : T P P, () var x:t P,,, yz, var x : int x:=2. y := x+z = x, x' : int x' =2

More information

Microsoft PowerPoint - string_kruse [兼容模式]

Microsoft PowerPoint - string_kruse [兼容模式] Strings Strings in C not encapsulated Every C-string has type char *. Hence, a C-string references an address in memory, the first of a contiguous set of bytes that store the characters making up the string.

More information

ebook8-30

ebook8-30 3 0 C C C C C C++ C + + C++ GNU C/C++ GNU egcs UNIX shell s h e l l g a w k P e r l U N I X I / O UNIX shell awk P e r l U N I X C C C C C C U N I X 30.1 C C U N I X 70 C C U N I X U N I X U N I X C Dennis

More information

Microsoft Word - CPE考生使用手冊160524.docx

Microsoft Word - CPE考生使用手冊160524.docx 大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該

More information

議 程 前 發 言 冀 新 官 上 任 燒 好 三 把 火 用 好 三 盆 水 陳 明 金 2014 年 11 月 18 日 澳 門 特 區 政 府 即 將 換 屆, 各 種 傳 聞 令 廣 大 居 民 感 覺 到, 絕 大 部 份 主 要 官 員 都 會 換 人 雖 然 他 們 對 人 選 無 話

議 程 前 發 言 冀 新 官 上 任 燒 好 三 把 火 用 好 三 盆 水 陳 明 金 2014 年 11 月 18 日 澳 門 特 區 政 府 即 將 換 屆, 各 種 傳 聞 令 廣 大 居 民 感 覺 到, 絕 大 部 份 主 要 官 員 都 會 換 人 雖 然 他 們 對 人 選 無 話 促 重 整 運 輸 部 門 冀 革 新 交 通 政 策 鄭 安 庭 議 員 議 程 前 發 言 2014 年 11 月 18 日 主 席 各 位 同 事 : 今 天 我 的 議 程 前 發 言 題 目 是 : 促 重 整 運 輸 部 門 冀 革 新 交 通 政 策 剛 剛 完 成 的 第 61 屆 澳 門 格 蘭 披 治 大 賽 車 令 到 遊 客 絡 繹 不 絕 的 澳 門 更 為 熱 烈, 關

More information

得 到 了 補 償. 對 於 武 姜 而 言, 莊 公 與 自 己 的 關 係 並 不 親 密, 而 共 叔 段 又 是 自 己 向 來 疼 愛 有 加 的 兒 子, 所 以, 對 莊 公 提 出 再 怎 麼 無 理 的 要 求, 武 姜 也 不 會 覺 得 有 什 麼 不 妥 之 處, 而 對 共

得 到 了 補 償. 對 於 武 姜 而 言, 莊 公 與 自 己 的 關 係 並 不 親 密, 而 共 叔 段 又 是 自 己 向 來 疼 愛 有 加 的 兒 子, 所 以, 對 莊 公 提 出 再 怎 麼 無 理 的 要 求, 武 姜 也 不 會 覺 得 有 什 麼 不 妥 之 處, 而 對 共 左 傳 - 鄭 伯 克 段 於 鄢 人 物 心 理 1021141 林 詩 倩 一. 緒 論 鄭 伯 克 段 於 鄢, 及 共 叔 段 之 亂, 是 魯 隱 公 元 年, 即 公 元 前 722 年, 春 秋 初 年 在 鄭 國 國 內 發 生 的 一 場 內 亂. 武 姜 成 為 武 公 夫 人 並 先 後 為 武 公 生 下 了 兩 個 兒 子, 長 子 莊 公 由 於 腳 先 出 來 造 成

More information

一 耀 州 青 瓷 的 裝 飾 手 法 與 紋 飾 種 類 耀 州 窯 的 裝 飾 紋 樣, 豐 富 多 變, 而 且 題 材 內 容 廣 泛, 組 合 形 式 多 樣, 圖 案 形 象 優 美, 令 人 賞 心 悅 目, 並 且 反 映 了 當 時 社 會 的 審 美 趣 味 和 理 想 裝 飾

一 耀 州 青 瓷 的 裝 飾 手 法 與 紋 飾 種 類 耀 州 窯 的 裝 飾 紋 樣, 豐 富 多 變, 而 且 題 材 內 容 廣 泛, 組 合 形 式 多 樣, 圖 案 形 象 優 美, 令 人 賞 心 悅 目, 並 且 反 映 了 當 時 社 會 的 審 美 趣 味 和 理 想 裝 飾 宋 代 耀 州 青 瓷 的 紋 飾 風 格 與 意 義 曾 肅 良 英 國 萊 斯 特 大 學 博 物 館 學 博 士 國 立 台 灣 師 範 大 學 美 術 研 究 所 助 理 教 授 摘 要 中 國 的 飲 茶 之 風, 興 於 唐 而 盛 於 宋, 特 別 是 宋 代 宮 廷 禁 苑 和 地 方 官 吏 文 人 學 士 的 尚 茶 崇 茶, 以 品 茶 為 雅 尚 的 觀 念 與 作 法, 使

More information

1911 年 武 汉 起 义, 广 东 独 立 胡 汉 民 任 总 督, 陈 任 广 东 军 政 府 外 交 部 副 部 长 陈 不 愿 做 官, 几 个 月 后 即 辞 职 1915 年 与 李 煜 堂 设 立 上 海 保 险 公 司, 陈 任 主 席 1921 年 孙 中 山 就 任 非 常 大

1911 年 武 汉 起 义, 广 东 独 立 胡 汉 民 任 总 督, 陈 任 广 东 军 政 府 外 交 部 副 部 长 陈 不 愿 做 官, 几 个 月 后 即 辞 职 1915 年 与 李 煜 堂 设 立 上 海 保 险 公 司, 陈 任 主 席 1921 年 孙 中 山 就 任 非 常 大 近 代 新 会 名 人 事 迹 张 云 田 : 新 会 县 双 水 区 人, 中 国 同 盟 会 员 华 侨 镇 南 关 起 义 烈 士 张 云 田 少 年 受 其 父 教 育, 精 通 文 翰, 其 时 深 受 外 国 嘲 笑 中 华 民 族 为 东 亚 病 夫 之 辱, 因 而 弃 文 就 武, 中 武 秀 才 中 年 时 结 交 三 合 会 兄 弟, 立 志 革 清 兴 华, 参 加 孙 中

More information

WWW PHP

WWW PHP WWW PHP 2003 1 2 function function_name (parameter 1, parameter 2, parameter n ) statement list function_name sin, Sin, SIN parameter 1, parameter 2, parameter n 0 1 1 PHP HTML 3 function strcat ($left,

More information

第七讲 继承与多态

第七讲  继承与多态 第 七 章 继 承 与 派 生 1 本 章 主 要 内 容 的 继 承 成 员 的 访 问 控 制 单 继 承 与 多 继 承 派 生 的 构 造 析 构 函 数 成 员 的 标 识 与 访 问 深 度 探 索 2 的 继 承 与 派 生 的 继 承 与 派 生 保 持 已 有 的 特 性 而 构 造 新 的 过 程 称 为 继 承 在 已 有 的 基 础 上 新 增 自 己 的 特 性 而 产 生

More information

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2 PowerBuilder 9 PowerBuilder Native Interface(PBNI) PowerBuilder 9 PowerBuilder C++ Java PowerBuilder 9 PBNI PowerBuilder Java C++ PowerBuilder NVO / PowerBuilder C/C++ PowerBuilder 9.0 PowerBuilder Native

More information

4 中 南 大 学 学 报 医 学 版 摘 要 目 的 探 讨 早 发 性 精 神 分 裂 症 患 者 在 静 息 状 态 下 是 否 存 在 脑 功 能 连 接 异 常 以 及 异 常 区 域 的 定 位 方 法 采 用 第 版 美 国 精 神 障 碍 诊 断 与 统 计 手 册 ( * ) (

4 中 南 大 学 学 报 医 学 版 摘 要 目 的 探 讨 早 发 性 精 神 分 裂 症 患 者 在 静 息 状 态 下 是 否 存 在 脑 功 能 连 接 异 常 以 及 异 常 区 域 的 定 位 方 法 采 用 第 版 美 国 精 神 障 碍 诊 断 与 统 计 手 册 ( * ) ( 中 南 大 学 学 报 医 学 版 3! + )! + - + - %$ 58: 58:7& * 1:D * $%&' 1&! & )& "# ( &!& )#% & '& '#! & #& & " ( ) 5*( )/ + ( / + + 6') * )* ) ; + *6 / + * ) *+ ' 6') * )+ * ) 6 9, * : + * ) *+ ) /+( * ( / * ) (

More information

! # % % & # # % #!& % &# % &# % % % # %& ( (!& (! & & % % #!! ) %&! *& % %! % %!! # % %!! %*!& % &# % &# ) ) ( % # # ) % ( (!& (! (!! # % % #!! # ( &!

! # % % & # # % #!& % &# % &# % % % # %& ( (!& (! & & % % #!! ) %&! *& % %! % %!! # % %!! %*!& % &# % &# ) ) ( % # # ) % ( (!& (! (!! # % % #!! # ( &! !#!#!%!&!& #!#!#!#!#!#!! #!% # ( )! & & % & ) % ( %! # )& ) &!) &!% )& )! )!!% & ( (!&!&!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! )! % * % * ( & )!! % & # %! %! )! % * % * ( & )!! % & # %! %! # )! % * % *

More information

## $%& %& ## () #) (( * (+++ () #) #) (+ (+ #) #) ( #, - #)). #))- # ( / / / 0 1 2 0 / $ # ( *. 3. 3 *..# 4 #$ 3 ( 5 ) ### 4 $ # 5, $ ## # 4 $# 5 ( %

## $%& %& ## () #) (( * (+++ () #) #) (+ (+ #) #) ( #, - #)). #))- # ( / / / 0 1 2 0 / $ # ( *. 3. 3 *..# 4 #$ 3 ( 5 ) ### 4 $ # 5, $ ## # 4 $# 5 ( % # # $ %& $ %# ( $ # ( # $ ( $ $ ( ( % ( $ ( $ ( ( % ( % $ ( $ ( ( $ ( ( ( & ( ( ( $ ( ( % %# ( ( $ ( %# % ## $%& %& ## () #) (( * (+++ () #) #) (+ (+ #) #) ( #, - #)). #))- # ( / / / 0 1 2 0 / $ # ( *.

More information

untitled

untitled 1 1.1 1.2 1.3 1.4 1.5 ++ 1.6 ++ 2 BNF 3 4 5 6 7 8 1.2 9 1.2 IF ELSE 10 1.2 11 1.2 12 1.3 Ada, Modula-2 Simula Smalltalk-80 C++, Objected Pascal(Delphi), Java, C#, VB.NET C++: C OOPL Java: C++ OOPL C# C++

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 float candy [ 365]; char code [12]; int states [50]; 2 int array [6] = {1, 2, 4, 6, 8, 10}; 3 // day_mon1.c: # include # define MONTHS 12 int

More information

C

C C 2017 4 1 1. 2. while 3. 4. 5. for 6. 2/161 C 7. 8. (do while) 9. 10. (nested loop) 11. 12. 3/161 C 1. I 1 // summing.c: 2 #include 3 int main(void) 4 { 5 long num; 6 long sum = 0L; 7 int status;

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

More information

《C语言程序设计》教材习题参考答案

《C语言程序设计》教材习题参考答案 教 材 名 称 : C 语 言 程 序 设 计 ( 第 1 版 ) 黄 保 和 江 弋 编 著 清 华 大 学 出 版 社 ISBN: 978-7-302-13599-9, 红 色 封 面 答 案 制 作 时 间 :2011 年 2 月 -5 月 一 思 考 题 1 常 量 和 变 量 有 什 么 区 别? 它 们 分 别 是 如 何 定 义 的? 常 量 是 指 在 C 程 序 运 行 过 程 中

More information

2007

2007 2007 年 上 半 年 软 件 评 测 师 考 试 浅 析 作 者 : 陈 嘉 祥 方 耀 公 司 : 广 东 亿 迅 科 技 有 限 公 司 ( 质 量 管 理 部 ) 1 简 介 1.1 目 的 本 文 章 主 要 介 绍 软 件 评 测 师 考 试 的 范 围 内 容 以 及 其 重 要 性, 还 有 相 关 的 试 题 分 析 1.2 适 用 范 围 有 意 参 与 或 将 来 有 意 参

More information

第3章.doc

第3章.doc 3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo

More information

IO

IO 1 C/C++ C FILE* fscanf fgets fread fprintf fputs fwrite C++ ifstream ofstream >>

More information

科学计算的语言-FORTRAN95

科学计算的语言-FORTRAN95 科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco Windows RTEMS 1 Danilliu MMI TCP/IP 80486 QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos ecos Email www.rtems.com RTEMS ecos RTEMS RTEMS Windows

More information

立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769

立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769 立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769 前 言 在 计 算 机 统 考 的 四 门 专 业 课 中, 最 难 拿 高 分 的 就 是 数 据 结 构 但 是 这 门 课 本 身 的 难 度 并 不 是 考 生 最 大 的 障 碍, 真 正 的 障 碍

More information

序 软 件 工 程 思 想 林 锐 序 软 件 工 程 思 想 讲 述 软 件 开 发 和 做 程 序 员 的 道 理, 视 野 独 特, 构 思 新 颖, 内 容 风 趣, 不 落 窠 臼, 令 人 耳 目 一 新 堪 称 难 得, 以 至 回 味 无 穷 作 者 从 事 了 八 年 的 软 件 开 发 工 作, 在 他 的 博 士 学 位 论 文 完 成 之 际 写 下 了 这 本 心 之 所 感

More information

3. 給 定 一 整 數 陣 列 a[0] a[1] a[99] 且 a[k]=3k+1, 以 value=100 呼 叫 以 下 兩 函 式, 假 設 函 式 f1 及 f2 之 while 迴 圈 主 體 分 別 執 行 n1 與 n2 次 (i.e, 計 算 if 敘 述 執 行 次 數, 不

3. 給 定 一 整 數 陣 列 a[0] a[1] a[99] 且 a[k]=3k+1, 以 value=100 呼 叫 以 下 兩 函 式, 假 設 函 式 f1 及 f2 之 while 迴 圈 主 體 分 別 執 行 n1 與 n2 次 (i.e, 計 算 if 敘 述 執 行 次 數, 不 1. 右 側 程 式 正 確 的 輸 出 應 該 如 下 : * *** ***** ******* ********* 在 不 修 改 右 側 程 式 之 第 4 行 及 第 7 行 程 式 碼 的 前 提 下, 最 少 需 修 改 幾 行 程 式 碼 以 得 到 正 確 輸 出? (A) 1 (B) 2 (C) 3 (D) 4 1 int k = 4; 2 int m = 1; 3 for (int

More information

第 期 周 超 英 等 甜 瓜 黑 斑 病 菌 的 生 物 学 特 性 及 室 内 药 剂 筛 选 * /3 / /5%.5 %: ' ' &-20 - &%3 - -- /%&% /.&.. 5 /05/ 07 /0/%&% /.&.38 /% -/.&.. 5 /05/ 07 05/ /8 00

第 期 周 超 英 等 甜 瓜 黑 斑 病 菌 的 生 物 学 特 性 及 室 内 药 剂 筛 选 * /3 / /5%.5 %: ' ' &-20 - &%3 - -- /%&% /.&.. 5 /05/ 07 /0/%&% /.&.38 /% -/.&.. 5 /05/ 07 05/ /8 00 第 卷 第 期 年 月!" # $ $" $"!%&' %' 文 章 编 号 ( * ) ' ' (''' 甜 瓜 黑 斑 病 菌 的 生 物 学 特 性 及 室 内 药 剂 筛 选 周 超 英 赵 杰 唐 赵 莲 支 月 娥 ' 上 海 市 浦 东 新 区 农 业 技 术 推 广 中 心 上 海 ' 上 海 市 浦 东 新 区 青 少 年 活 动 中 心 上 海 ' 上 海 交 通 大 学 农 业

More information