ebook55-1
|
|
|
- 黠 毕
- 9 years ago
- Views:
Transcription
1 1 O O P O O P C + + [1] S i m u l a - 67 O O P O O P S m a l l t a l k C++ O O P [1] The Tao of Objects Gary Entsminger
2 2 C O O P O O P
3 v i r t u a l v i r t u a l C + + Vi r t u a l OOP C C++ C C + + m a i n () C C + + C 1.2 C++ C + + C O O P C O O P C C C C + + O O P C + + C + + C C C + + C C + +
4 4 C + + C + + r e f e r e n c e s ( ) C C + + C C + + C C + + C C + + C C + + C + + C C + + C + + C 10 % O O P C C + + C
5 C C B A S I C C C B A S I C C + + h e l l o - w o r l d O O P 1.3 O O P C + + C + + C ) 2)
6 6 C C F O RT R A N F O R m u l a - T R A N s l a t i o n C O B O L COmmon Business-Oriented Language L i s p L i s t - P r o c e s s i n g A P L A Programming L a n g u a g e L i s p A P L m i s s i o n F O RT R A N C O B O L F O RT R A N C O B O L A l g o l P a s c a l P r o l o g F O RT H F O RT H B A S I C Beginners All-purpose Symbolic Instruction Code 60 A P L B A S I C A P L
7 F o o b l e B l a h 1.
8 8 C + + 1) 2) % 2 0 % 20 % 3. OOP O O P O O P
9 O O P O O P O O P [ 1 ] 1) 2) 3) 4) 5) 1) 2) 3) 4) 5) [1] Design Patterns:Elements of Reusable Object-Oriented Software by Erich Gamma et al., Addison-We s l e y, 1995
10 10 C O O P C + + [ 1 ] 2. O O P C + + 1) 2) [1] A reference to vampires made in The Mythical Man-Month, by Fred Brooks, Addision-We s l e y, 1975
11 ) 2) 3. 1) 2) 3) 4) 5) C + + O O P 6) 7) 4. Michael Wi l k O O P 5.
12 12 C + + Software Creativity Robert Glass P r e n t i c e - H a l l, 1995 G l a s s P. J. P l a u g e r [ 1 ] Pe o p l e w a r e Tom Demarco Timothy Lister Dorset House,1987 X Y Z C o m p l e x i t y, M. Mitchell Wa l d r o p Simon & Schuster, 1992 Santa Fe, New Mexico 1.4 Robert McKee [2] M c K e e [1] Object Lessons Tom Love, SIGS Books, 1993 [2] Through Two Arts, Inc.,12021 Wilshire Blvd. Suite 868, Los Angeles, CA 90025
13 ) C + + 2) C + + D B M S D B M S w i l d - c a r d [ 1 w i l d - c a r d ] w i l d - c a r d w i l d - c a r d w i l d - c a r d O O P B r o o k s [2] O O P [1] w i l d - c a r d [2] The Mythical Man-Month,
14 14 C + + O O P [ 1 ] C + + [ 2 ] (treatment) [1] Microsoft Wo r d [2]
15 derived:public base O c c a m s Razor 3. o o p o o p
16 16 C main( ) main( ) 2. 1) 2) 3) / / # [ 1 ] // #[2] Rich Text Format(RT F ) 4) 5)
17 # i n c l u d e m a i n () A B C m a i n () [ 1 20 ] [1] Object Analysis and Design:Description of Methods, edited by Andrew T. F.Hutt of Object Management Group(OMG),john Wiley & Sons, 1994
18 18 C Booch B o o c h [1] O O P CRC Class, Responsibility, Collaboration, CRC) B o o c h / C R C [1] Object-Oriented Design with Applications by Grady Booch, Benjamin Cummings, C + +
19 RDD [1] C R C B o o c h R D D R D D 1) 2) 3) 4) OMT [ 2 ] O M T B o o c h R D D O M T 1) B o o c h R D D 2) 3) 1.6 OOP O O P O O P C C OOP O O P C C 6 9 [1] Designing Object-Oriented Software by Rebecca Wirfs-Brock et al., Prentice Hall, 1990 [2] Object-Oriented Modeling and Design by James Rumbaugh et al., Prentice Hall,1991
20 20 C O O P C [1] 4. C + + m a i n ( ) O O P C C + + C + + C C + + C + + O O P C + + C C + + O O P C C + + C + + [1] Camma et al.,
21 1 21 C O O P O O P C + + C + + C C % C + + C C++ C C C + + C C + + C C O O P C + + O O P 1.7 C + + O O P C + + O O P O O P O O P C + + O O P C + + C + C + + C + +
22
23 2 C + + C L I B L I B U N I X Wi n d o w s D D L D D C + + C C A int A e x t e r n e x t e r e x t e r n
24 2 23 int f(float,char); f C + + C C + + g r e p a w k 2.2 C C C s t r u c t s t r u c t C s t r u c t s t r u c t s t a s h
25 24 C + + s t r u c t s t r u c t C t y p e d e f s t r u c t s t r u c stash A, B, C; C C C s t o r a g e unsigned char* C s t a s h v o i d * O B J L I B D D L
26 2 25 #include #include
27 26 C + + initialize( ) struct stash s t o r a g e size add( ) s t a s h inflate( ) v o i d * C memcpy( ) memcpy( ) &(S->storage[S->next * S->size]) n e x t & memcpy( ) n e x t fetch( ) fetch( ) add( ) C count( ) struct stash i n t S t a s h i n t S t a s h. n e x t c o u n t (& i n t S t a s h ) s t a s h s t r u c t n e x t n e x t s t a s h s t o r a g e 200 a i r p l a n e 20 C malloc( ) calloc( ) realloc( ) free( ) inflate( ) realloc( ) s t a s h realloc( ) initialize( ) realloc( ) assert( ) malloc( ) calloc( ) realloc( ) C free( ) Microsoft Wi n d o w s
28 2 27 assert( ) A S S E RT. H assert( ) C 17 C + + free( ) free( ) malloc( ) calloc( ) realloc( ) cleanup( ) s t a s h i n t 80
29 28 C + + main( ) s t a s h i n t S t a s h s t r i n g S t a s h L I B T E S T.C stringstash C s t a s h fopen( ) FILE struct FILE struct fgets( ) fclose( ) FILE struct s t r u c t C s t a s h i n t S t a c f o r count( ) s t r i n g S t a s h w h i l e fetch( ), C C C i n t i n t LIB.H stash C C void foo(float) i n t f l o a t.o.obj L I B T E S T.C initialize( ) fetch( ) ( ) LIB.C, L I B T E S T.C
30 2 29 C f o o ( i n t ) f o o ( f l o a t ) _ f o o _ f o o foo( ) i n t foo( ) f l o a t f l o a t 2.3 c p p : cpp libtest.c lib.c U N I X make m a k e [1] make make make makefile makefile m a k e f i l e C. h.c C++ Unix.H.C M S - D O S DOS C++.hxx. c x x C C + +. c p p. h 2.4 stash C [1] C++ Inside & Out, (Osborne/McGraw-Hill,1993)
31 30 C + + C C initialize( ) cleanup( ) C C C initialize( ) cleanup( ) stash_initialize( ) stash_cleanup( ) struct s t r u c t C + + struct s t r u c t struct 2.5 C + + stash // C C C + + //
32 2 31 t y p e d e f C + + t y p e d e f i n t c h a r f l o a t d o u b l e stash s t r u c t C C + + C stash A, B, C; add( ) C stash_initialize( ) stash_cleanup( ) struct stash initialize( ) initialize( ) initialize( ) struct stash s t r u c t C + + :: struct initialize( ) s t a s h stash::initialize(int Size, int Quantity) stash C + +
33 32 C + + C++ C struct s->size = size size = size s - > C++ C + +
34 2 33 C S stash* C + + t h i s s t r u c t C S C this->size = Si z e ; t h i s C inflate( ) v o i d * S->storage = v; C++ C v o i d * malloc( ) calloc( ) realloc( ) C C + + C + + C + + s t r u c t C++ s t r u c t s t r u c t C + + v o i d * void* void* void* calloc( ) realloc( ) unsigned char* C + + C C C C++ C C++ C C++ C C + + C C + + stash C + +
35 34 C + +. this C + + intstash.initialize(sizeof(int), 100) s t a s h _ i n i t i a l i z e (& i n t S t a s h, sizeof(int), 100) C + + c f r o n t AT & T C C c f r o n t C + + C C++ while(cp = (char*)stringstash.fetch(i++)) C C++ C
36 2 35 C struct O O P O O S i m u l a S c a n d i n a v i a S i m u l a Simula class C++ o b j e c t - b a s e d C [ 1 ] f l o a t float int stash add( ) fetch( ) inflate( ) stash S s t a s h float f float stash s t a s h abstract dada type C + + s t a s h stash o b j e c t. m e m b e r _ f u n c t i o n ( a rg l i s t ) stash S S. a d d (& i ) S add( ) C C C C s t r u c t C struct C++ C C + + C [1]
37 36 C + + struct s i z e o f struct 200 int struct B s t r u c t C C++ s t r u c t printf () sizeof C++ C C C C C++ C P P
38 2 37 C P P C C++ C++ C++ F O O. H FOO.H #ifndef FOO_H_ #define FOO_H_ // Rest of header here... #endif // FOO_H_ C C++ main( ) 2.10
39 38 C + + struct l i n k link link next head struct link link* head C initialize( ) stack initialize( ) cleanup( ) push( ) pop( ), d a t a data peek( ) data cleanup data
40 2 39 struct stack::link::initialize( ) stack::initialize( ) head stack::push( ) stack malloc( ) link l i n k initialize( ) link next h e a d head link link stack::pop( ) data head stack::cleanup( ) cursor free( ) l i n k d a t a link
41 40 C + + A A
42 2 41 S::f( ) f( ) A 2.11 C++ C + + struct ) struct 2) 3) 4) 5) C++ struct typedef
43
44 3 C C + + s t r u c t s t r u c s t r u c t t y p e d e f C + + s t r u c t 3.1 C s t r u c t s t r u c i n i t i a l i z e () c l e a n u p () s t r u c t C s t r u c t s t a c k malloc() 3.2 C++ C + + s t r u c t p u b l i c p r i v a t e p r o t e c t e d s t r u c t p u b l i c p u b l i s t r u c t s t r u c t
45 3 43 p r i v a t e p r i v a t e struct B
46 44 C + + f o o () B m a i n () s t r u c t s t r u c t protected) p r o t e c t e d p r o t e c t e d p r i v a t e p r o t e c t e d p r i v a t e s t r u c t s t r u c s t r u c t s t r u c t
47 3 45 struct Y f( ) X C + + struct Y Y :: f(x*) struct X Y :: f(x*) struct X Y :: f(x*) X X Y :: g(x) X Y :: f(x*) struct X X s t r u c t, struct X Y :: f(x*) Y g( ) g( f r i e n d s t r u c t s t r u c t :friend struct Z s t r u c t s t r u c t s t r u c t
48 46 C + + s t r u c t f r i e n d
49 3 47 struct holder p o i n t e r, p o i n t e r p o i n t e r h o l d e r s t r u c t p o i n t e r h o l d e r friend holder : :pointer ; s t r u c t p o i n t e r p o i n t e r h o l d e r main( ) p o i n t e r C h o l d e r
50 48 C f r i e n d C + + f r i e n d C C s t r u c t C + + s t r u c t C + + C struct C s t r u c t C + + C + + C C + + s t r u c t s t r u c t C C + + s t r u c t 3.5 s t r u c t p r i v a t e C s t r u c t S i m u l a - 67 c l a s s S t r o u s t r u p C + +
51 3 49 C s t r u c t c l a s s C + + s t r u c t c l a s s s t r u c t p u b l i c C + + c l a s s c l a s s S t r o u s t r u p s t r u c t s t r u c t p u b l i c
52 50 C + + m X Y x m stash 2
53 3 51 i n f l a t e ( ) a d d ( ) stack s t a c k s t a c k 3.6 handle classes C + + C
54 52 C handle classes Cheshire Cat [ 1 ] s m i l e struct cheshire; cheshire [1] John Carolan Lewis Carroll C + +
55 3 53 cheshire struct handle::cheshire { [ 1 h a n d l e :: i n i t i a l i z e () cheshire struct ] h a n d l e :: c l e a n u p () H A N D L E. C P P c h e s h i r e H A N D L E. C P P h a n d l e [1] 12 n e w
56 54 C C ) p u b l i c private p r o t e c t e d 2) f r i e n d 3) H A N D L E. C P P c h e s h i r e U S E H A N D L. C P P
57 4 2 C s t r u c t C C + + C + + C C + + C s t r u c t s t r u c t C s t r u c t C + + C s t a s h s t a c k i n i t i a l i z e () C + + S t r o u s t r u p 3
58 56 C + + a a X :: X () t r e e tree t(12); // 12 t r e e ( i n t ) i n i t i a l i z e () C + + v o i d 4.2 C?? C + + ~ class Y { p u b l i c : } ; ~ Y ( ) ;
59 4 57 g o t o C g o t o C + + g o t o C setjmp() l o n g j m p ()
60 58 C C P a s c a l C + + C C + + C C C + + C + +
61 4 59 b u f x y g C for C + + f o r f o r C + + i j f o r C f o r i j i _ l o o p _ c o u n t e r i C + + f o r
62 60 C C s w i t c h g o t o g o t o s w i t c h 12
63 stash c l e a n u p () s t a s h i n i t i a l i z e ( ) i n i t i a l i z e () c l e a n u p ()
64 62 C + + s t a s h
65 4 63 c l e a n u p () i n t S t a s h s t r i n g S t a s h 4.5 stack s t a c k s t a c k l i n
66 64 C + + l i n k s t a c k : : p u s h [ 1 ] C + + [1]
67 4 65 n e w 12 C s t a c k t e x t l i n e s 4.6 s t r u c t c l a s s C + + int a[5]={1,2,3,4,5};
68 66 C + + int b[6]={0}; 0 f o r 1 f o r int c[] = {1,2,3,4}; sizeof c/sizeof *c( ) for(int i = 0; i< sizeof c / sizeof *c; i++) c [ i ] + + ; s t r u c t C s t r u c struct X { } ; int i; float f; char c; X x1 = {1,2.2,'c' }; s t r u c t X x2[3] = {{1,1.1, 'a'},{2,2.2, 'b'}}; s t r u c t s t r u c t struct Y { } ; float f; int i; Y(int A); // presumably assigned to i Y y2[] = {Y(1),Y(2),Y(3)}; s t r u c t c l a s s,
69 v a n i l l a, Y Y y4[2] = {Y(1)} Y Y y5[7] Y y; struct c l a s s class Z { int i; // private }; // no constructor Z z,z2[10]; C C + + C + + C C + + C s t r u c t
70 68 C + + C + + C C + + C C + + C + + C C + + C + C 4.8 C + + S t r o u s t r u p C + + C C ) 3 HANDLE.H,HANDLE.CPP USEHANDL.CPP 2) 3) 4)
71 5 p r i n t _ i n t () p r i n t _ c h a r ( ) p r i n t _ f l o a t ( ), C + + C + + f ( h e l l o ), f ( h i, 1 ) f ( h o w d y, 2, c ) 5.1 2
72 70 C + + void f(); class x {void f();}; x f f x :: f () 2 _ f _ x _ f void print(char); void print(float); _ p r i n t _ p r i n t _ c h a r _ p r i n t _ f l o a t void f(); int f(); int x = f(); C C C C + +
73 5 71 //: DEF.CPP -- Function definition void f(int) {} //: USE.CPP -- Function misdeclaration void f(char); main() { //! f(1); //Causes a linker error } f ( i n t ), ( ) f ( c h a r ) C C + + f _ i n t f _ c h a r f _ c h a r f _ i n t C + + C 5.2 s t a s h s t a s h () Q u a n t i t y q u a n t i t y s t o r a g e
74 72 C + +
75 5 73 s t o r a g e, a d d () a d d ()
76 74 C + + s t a s h 5.3 s t a s h C + + s t a s h stash(int Size);// zero quantity stash(int Size,int Quantity); stash(int Size, int Quantity=0); s t a s h ( i n t ) s t a s h ( i n t, i n t stash A(100),B(100,0); A void fn(int x /* =0*/ ) { //... void f(int X, int = 0, float =1.1); C + + void f(int X, int,float f) {/*...*/} x f, p l a c e h o l d e r, f ( 1 ) f ( 1, 2, 3. 0 )
77 5 75 o n o ff
78 76 C + + b i t s () B i t Ve c t o r B i t Ve c t o r b i t s () b i t s ( i n t )
79 B i t Vector b(0) 8 B i t Vector char* 0 B i t Ve c t o r B i t Vector b((unsigned char * )0) B i t Vector b b. b i t s ( 64 ), 8 c h a r * unsigned char* B i t Vector(unsigned char*,int) B i t Ve c t o r ( c h a r *) p r i n t () c h a r * B i t Ve c t o r s e t () c l e a r () r e a d (), p r i n t () B i t Ve c t o r 0 1 B i t Ve c t o r 8 B i t Ve c t o r p r i n t ( )
80 78 C + +
81 5 79 f o r f o i n i t [ i n d e x ]&( 0 x 80 > > o ff s e t ) 16 0 x 80 1 o ff s e t 1 s e t () B i t Vector p r i n t () 0 1 B i t Ve c t o r
82 80 C n u m B y t e s 8 0 s e t () c l e a r () r e a d () a s s e r t ( S e t () r e a d () 1 s e t () 1 r e a d () c l e a r ( 1 ~ s e t () r e a d () c l e a r () c l e a r () bytes[bit/char_bit]&=~(1<<(bit % CHAR_BIT)) b i t s () r e a l l o c () b y t e s r e a l l o c () p r i n t () m s g C p u t s () r e a d () 8 B i t Ve c t o r p r i n t () B i t Ve c t o r B i t Ve c t o
83 5 81 b v 1 b v 2 b v 3 B i t Ve c t o r s e t () c l e a r () r e a d () p r i n t () b v 2 B i t Ve c t o r C + + b i t s b i t s t r i n g 5.4 B i t Ve c t o r b i t s () int bits(int sz=-1); - 1 b i t s - 1 int i=bv1.set(10); - 1
84 82 C ) m e s s a g e c h a r * c h a r * p r i n t (); c h a r * 2) 3) S TA S H 4. H S TA S H 4. C P P s t a s h 4) f l a g s B i t Ve c t o r s e t () c l e a r () r e a d () i n d e x o ff s e t m a s k 5) F L A G S. C P P 100
85 6 C I / O I / O I / O C C + + C I/O 6.1 C C C c l o s e () C I / O r I / O fp( )
86 84 C + + fopen( ) exit( ) fp( ) f I / O fp( ) fp( ) f p () f f f p () I / O C C + +
87 6 85 p r i n t f ( ) S T D I O. H I / O v f p r i n t f () F i l e F i l F i l e F i l e f 0 f
88 86 C F F F i l e [ 1 ] I / O / 1) p r i n t f ( " % c ", ' x ' ) ; 2) p r i n t f () 3) p r i n t f () C + + I / O 4) C + + p r i n t f () C p r i n t f () s c a n f () p r i n t f () C C + + I / O h e l l o, w o r l d, I / O C + + I / O I / O C C + + < < > > 5 [1] FULLWRAP test file
89 6 87 C + + C C + + 1) C C + + C + + C C + + C 2) C + + C ++ C C C < < < < 1 ; < < > > i s t r e a m o s t r e a m ( i f s t r e a m s ) ( o f s t r e a m s ) c h a r * i s t r s t r e a m s ( o s t r s t r e a m s ) C + + s t r i n g i s t r i n g s t r e a m s ( o s t r i n g s t r e a m s ) I / O c i n c i C s t d i n I O S T R E A M. H
90 88 C + + > > > < < c o u t ( c e r r ) p r i n t f () 1. e n d l c o u t < < f l u s h o c t ( ) d e c ( ) h e x ( ) c o u t < < h e x < < " 0 x " < < i < < e n d l c i n > > w s e n d s e n d l s t r s t r e a m s I O S T R E A M. H I O M A N I P. H c i n > > c o u t < < s c a n f ()
91 6 89 b u f t h i s b u f b u c i n
92 90 C + + G U I I / O c i n 1) G U I 2) 3) c o u t c o u c o u t g e t g e t l i n e \ n g e t g e t g e t g e t l i n e g e t l i n e 1. get g e t i n r e a d w r i t e 3. g e t g e g e t l i n e g e t E O F g o o d e o f f a i l b a d e o f b i t f a i l b i t b a d b i t r e a d
93 6 91 w h i l e ( c i n ) i f ( c i n ) i f c i n e o f b i t f a i l b i t [ 1 c l e a r () ] 6.3 C S T D I O. H c l o s e o f s t r e a m F S T R E A M. I / O I O S T R E A M. H [1]
94 92 C + + i f s t r e a m o f s t r e a m a s s e r t () (, 11 ) w h i l e g e t () S Z - 1 \ n g e t g e t g e i n. g e t () g e t i n i g n o r e 1 i g n o r e () E O F c o u t o u t o s t r e a m g e t l i n e o u t c l o s e o p e n i n 12 w h i l e g e t l i n e \ n g e t l i n e () g e t () i o s :: i n i o s :: o u t i o s :: a p p i o s :: a t e i o s :: n o c r e a t e i o s :: n o r e p l a c e i o s :: t r u n c i o s :: b i n a r y i f s t r e a m i o s :: a p p i o s :: a t e i o s :: i n o f s t r e a m i o s :: t r u n c
95 6 93 O R 6.4 I / O s t r e a m b u f s t r e a m b u f I / O s t r e a m b u f s t r e a m b u f s t r e a m b u f s t r e a m b u f s t r e a m b u f s t r e a m b u f r d b u f () s t r e a m b u f s t r e a m b u f s t r e a m b u f < < < < i f s t r e a m a s s e r t ( i n ) c o u t < < i n. r d b u f ( ) c o u t streambuf get() g e t s t r e a m b u f s t r e a m b u
96 94 C g e t r d b u f () g e t i g n o r e g e t () 6.5, s t r e a m p o s C f s e e k () s t r e a m p o s t e l l t e l l p t e l l g p g s t r e a m p o s s e e k p s e e k g s t r e a m p o s s e e k p s e e k g I o s : : b e g I o s : : c u r I o s : : e n d C C + + S T D I O. H C + + ( c i n c o u t )
97 6 95 i f s t r e a m a s s e r t s e e k g s t r e a m p o s l o n g t y p e d e f t e l l g 1 / 10 s t r e a m p o s s p 2 s e e k g r d b u f s t r e a m b u f s e e k g streampos sp2 / s t r e a m b u f i f s t r e a m i f s t r e a m o s t r e a
98 96 C + + i o f i l e. o u t c o u t < < i n 2. r d b u f () Where does this end up? s e e k p s e e k g o u t strstreams s t r s t r e a m s t r s t r e a i s t r s t r e a m s t r s t r e a m o s t r s t r e a s t r s t r e a m s i s t r s t r e a m s b u f [ s i z e ] i s t r s t r e a m [ 1 ] [1] D O S
99 6 97 C a t o f () a t o i () istrstream s(" This is a test") s > > i > > f i f This is a test i 1 f b u f 2 r d b u f s t r s t r e a m s o s t r s t r e a m : : o s t r s t r e a m ( c h a r *, i n t, i n t = i o s : : o u t ) i o s :: a t e i o s :: a p p o s t r s t r e a m s e n d s o s t r s t r e a m
100 98 C + + i n t f l o a t r d b u f ( c o n t r o l - Z ( u n i x c o n t r o l - D ) g e t l i n e b u f b u f ostrstream os i o s :: a p p b u f o s t r s t r e a m e n d s e n d l b u f c o u t < < b u f o s. r d b u f () s t r e a m b u f c o u t < < o s. r d b u f () s t r s t r e a m s i s t r s t r e a m s o s t r s t r e a m ostrstream A A s t r s t r e a m s t r e a m b u f A s t r char* cp=a.str() A A A o s t r s t r e a m s t r c h a r *
101 6 99 s t r o s t r s t r e a m o s t r s t r e a m o s t r s t r e a s t r () c h a r * C + + n e w d e l e t e 12 C m a l l o c () f r e e () n e w d e l e t e C + + n e w o s t r s t r e a m n e w d e l e t e ostrstream A s t r () c h a r * delete A.str() o s t r s t r e a m f r e e z e () f r e e z e () o s t r s t r e a m s t r e a m b u f f r e e z e A. r d b u f ( ) - > f r e e z e ( 0 ) A A s t r s e n d s s t r () c h a r * s s e n d s s e e k p r d b u f () f r e e z e ( 0 ) s t r e a m b u f s
102 100 C + + s s t r ( ) o s t r s t r e a m o s t r s t r e a m c h a r * o s t r s t r e a m r d b u f () o s t r s t r e a m 1. s t r () o s t r s t r e a m s t r s s t r c h a r * c h a r * d e l e t e s t r () c h a r * v o i d * c h a r * < < v o i d * < < s t r () s 0 o s t r s t r e a m 2. C++ string s t r i n g s t r e a m [ 1 c h a r * s t r s t r e a m ] 6.7 p r i n t f () [1]
103 i o s I O S T R E A M. H i o s :: f l a g s () long(typedefed to fmtflags) s e t f ( ) o n o ff o n / o ff s e t f ( f m t f l a g s ) o n u n s e t f ( f m t f l a g s ) o ff o n / o ff i o s : : s k i p w s i o s : : s h o w b a s e i o s : : s h o w p o i n t i o s : : u p p e r c a s e i o s : : s h o w p o s i o s : : u n i t b u f i o s : : s t d i o C + + A - F E + C I / O c o u t c o u t. s e t f ( i o s :: s h o w p o s ) c o u t. u n s e t f ( i o s : : s h o w p o s ) C I / O C i o s :: s t d i o p r i n t f () 1. s e t f i o s :: b a s e f i e l d i o s d e c s e t f i o s :: h e x i o s :: h e x i o s :: d e c s e t f () s e t f ( i o s :: h e x, i o s :: b a s e f i e l d ) i o s :: b a s e f i e l d i o s :: h e x s e t f () h e x ()
104 102 C + + s e t ( ) i s o : : b a s e f i e l d i o s : : d e c i o s : : h e x i o s : : o c t i o s :: f l o a t f i e l d i o s :: s c i e n t i f i c i o s :: f i x e d a u t o m a t i c (Neither bit is set) i o s : : a d j u s t f i e l d i o s : : l e f t i o s : : r i g h t i o s : : i n t e r n a l 2. f u n c t i o n int ios::width() int ios::width(int n) int ios::fill() int ios::fill(int n) int ios::precision() int ios::precision(int n) 0 6 i o s :: floatfield w i d t h () 6.7.2
105 6 103
106 104 C + + D a s t r i n g i z i n g a D a a T
107 6 105
108 106 C C + + I O S T R E A M. H d e c o c t h e x s e t f ( i o s :: d e c, i o s :: b a s e f i e l d ) s e t f ( i o s :: o c t, i o s :: b a s e f i e l d ) s e t f ( i o s :: h e x, i o s :: b a s e f i e l d ) IOSTREAM.H [ 1 ] w s e n d l e n d s f l u s h s h o w b a s e n o s h o w b a s e s h o w p o s n o s h o w p o s u p p e r c a s e n o u p p e r c a s e s h o w p o i n t n o s h o w p o i n t s k i p w s n o s h i p w s l e f t r i g h t i n t e r n a l s c i e n t i f i c f i x e d C A - F E s e t p r e c i s i o n ( ) i o s : : p r e c i s i o n ( ) I O M A N I P. H setiosflags(fmtflags n) resetiosflags(fmtflags n) setbase(base n) setfill(char n) setprecision(int n) setw(int n) n i o s :: s e t f () n i o s :: u n s e t f () n n n 0 10 C x f 1 5 d e c o c t h e x n i o s f i l l n i o s p r e c i s i o n n i o s w i d t h [1]
109 6 107
110 108 C + + s e t i o s f l a g s ( ) r e s e t i o s f l a g s ( ) O R s e t f () u n s e t f () 6.9 e n d l o s t r e a m 10 e n d l ostream& endl(ostream&) cout<<"howdy" <<endl e n d l I O S T R E A M. H o s t r e a m n l
111 6 109 o s < < ' \ n ' [ 1 o s n l ] n l e n d l Jerry Schwarz [2] < < < < 11 [1] n 1 8 [2]
112 110 C + + f i x w c h a r * < < f i x w o s t r e a m o s t r e a m f i x w cout <<fixw(string,i)<<endl f i x w < < bin U L O N G _ M A X unsigned long L I M I T S. H c h a r * f i x w unsign long b i n f i x w b i 9
113 u n i x s e d a w k s e d a w k m a i n i o s :: n o r e p l a c e i s t r s t r e a m C t o u p p e r () i n t c h a r 1.
114 112 C + + N A M E. H N A M E. C P P
115 6 113
116 114 C + +
117 6 115 o s t r s t r e a m enum bufs o s t r s t r e a m c h a r b c h a r b u f n u m b u f n u m b u f s e n u m b u f n u m b u f b S Z b a s e h e a d e r i m p l e m e n t C P P H l i n e 1 guard1 g u a r d 2 g u a r d 3 C P P l i n e l C P P i n c l u d e C P P o s a r r a y o s t r s t r e a m o s t r s t r e a m b u f s b o s a r r a y b o s t r s t r e a m C P P i f s t r e a m s s t r s t r e a m // C s t r s t r () o s t r s t r e a m s t r s t r () s t r s t r e a m o s t r s t r e a o f s t r e a m o s t r s t r e a m 2. //
118 116 C + +
119 6 117 m a k e r m a k e r strstream edited e d i t e d
120 118 C + + p r i n t f ( ) d a t a p o i n t o s t r e a m p r i n t f ()
121 6 119 p r i n t f () s e t f () p r e c i s i o n ( 4 s e t w () 2 s e t w () 10 0 * ` ` ` 1. w r i t e (),
122 120 C + + d a t a p o i n t : : p r i n t ( ) A S C D ATA. T X T A S C D ATA. B I N i o s :: b i n a r y C t i m e (), t i m e _ t GMT C s c r a n d () t m
123 6 121 t m C l o c a l t i m e () t m t m l o c a l t i m e () l o c a l t i m e () l o c a l t i m e () d a t a p o i n t tm struct l o c a l t i m e () d. Ti m e = * l o c a l t i m e ( & t i m e r ) t i m e r 55 C r a n d () R A N D _ M A X % r a n d () D ATA. B I N R A M w r i t e () unsigned char* d a t a p o i n t d a t a p o i n 2. D ATA 2. T X T D ATA. T X T
124 122 C + + ifstream bindata D ATA. B I N
125 6 123 i o s : : n o c r e a t e a s s e r t () r e a d ( datapoint d d a t a p o i n t r e a d () b i n d a t a f a i l b i t w h i l e c l e a r () f a i l b i t r e c n u m 4 s e t w () r e a d () e l s e f a i l b i t c l e a r () r e a d () f l a t - f i l e D B M S A p p l e B A S I C D B M S C ) in i f s t r e a m o s o s t r s t r e a r d b u f () o s t r s t r e a m s t r () o s c h a r * C toupper() o s 2) 3) 1 4) g r e p
126
127 7 c o n s t C + + C c o n s t v o l a t i l e, c o n s t c o n s t # d e f i n e s 7.1 C C + + c o n s t C #define BUFSIZE 100 B U F S I Z E B U F S I Z E C + + c o n s t const bufsize=100 const int bufsize=100 b u f s i z e char buf[bufsize] c h a r i n t f l o a t d o u b l e c o n s t c o n s # d e f i n e const # d e f i n e c o n s t c o n s t
128 7 125 c o n s t C + + c o n s c o n s t c o n s t c o n s t e x t e r n extern const bufsize e x t e r n c o n s t C + + c o n s t c o n s t c o n s t c o n s t c o n s t c p p c o n s t const c o n s t # d e f i n e s c o n s t i j i j j j j b u f j m a i n () c c o n s t C c 2 c # d e f i n e
129 126 C + + c o n s t c o n s t c o n s t C C + + C C c o n s t C C c o n s t C const bufsize=100 char buf[bufsize] b u f s i z e C const bufsize C + + C C c o n s t C + + c o n s t C + + C e x t e r n extern const bufsize;//declaration only C C c o n s t c o n s t C # d e f i n e
130 c o n s t c o n s t c o n s t c o n s t c o n s const c o n s t const int* x x const int x c o n s t x c o n s t int const* x x i n t c o n s t x c o n s t i n t c o n s t i n t const c o n s t c o n s t * int d=1 int* const x=&d x i n t c o n s t c o n s t * x = 2 c o n s t c o n s int d=1 const int* const x=&d // (1) int const* const x2=&d // (2) c o n s t * int* u=&w
131 128 C + + i n t * * int* u=&w v = 0 int* u int v C + + c o n s t c o n s t c o n s t c o n s t c o n s c o n s t c o n s t C + + c o n s t c o n s t char* cp="howdy" h o w d y 7.3 c o n s t c o n s t c o n s t const c o n s t
132 7 129 x ( ) c o n s t c o n s t c o n s 10 & c o n s t const const int g() c o n s t c o n s t
133 130 C + + f 5 ( ) const X f 6 () const X c o n s t c o n s t c o n s t f 7 () c o n s t C c o n s t
134 c o n s t c o n s t c o n s t c o n s t c o n s t t () c o n s t u () c o n s t
135 132 C + + u () c o n s t c o n s t c o n s t c o n s v () w () v () const char* v () w () v ( w () m a i n () t ( c o n s t c o n s t t () u () c o n s t c o n s t c o n s t v () c o n s t w () c o n s t const int* const int* const int*const c o n s t C C + + C + + c o n s t c o n s t C c o n s t
136 7 133 f () X f () g 1 () g 2 () g 1 g 1 () c o n s t g 2 () 7.4 c o n s t c o n s t c o n s t c o n s t c o n s t const enum c o n s t # d e f i n e s i z e s i z e # d e f i n e # d e f i n c o n s t c o n s t C c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t 1. c o n s t c o n s
137 134 C c o n s t float pi ( ) i n t e g e r i n t e g e r integer I[100] f o r m e m s e t () c o n s t c o n s t C c o n s t c o n s t e n u m
138 7 135 e n u m enum { one=1,two=2,three} e n u m t h r e e 3 e n u m
139 136 C + + p u s h () const char* p o p () const char* s t a c k const char* s t r i n g s t a c k i c e C r e a m S t r i n g s t a c k e n u m C + + static const 9 C C + + C + + C a c o l o r C a + + C + + C + + c o l o r i n t 1 i n t c o l o r C + + c o l o r i n t b l u e 1 c o l o r 1 e n u m e n u const c o n s t c o n s t c o n s t const int i=1 const blob B(2)
140 7 137 B b l o b c o n s t 2 c o n s t c o n s t c o n s t c o n s c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s c o n s t int X::f() const {return i } f () i c o n s t c o n s t c o n s c o n s t c o n s t
141 138 C + + c o n s t q u o t e () c o n s t l a s t q u o t e L a s t q u o t e () c o n s t c o n s c q c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t c o n s t t h i s t h i s c o n s t
142 7 139 t h i s c o n s t m u t a b l e c o n s t c o n s t c o n s t R O M
143 140 C + + c o n s t c o n s t c o n s m u t a b l e c o n s t c o n s t 1) class s t r u c t 2), c o n s t R O M R O 7.5 volatile v o l a t i l e c o n s t v o l a t i l e v o l a t i l e v o l a t i l e c o n s t v o l a t i l e const volatile
144 7 141 c o n s t v o l a t i l e v o l a t i l e v o l a t i l e i s r () t h i s I S R i s r ( ) v o l a t i l e c o n s t c - v 7.6 c o n s t const correctness c o n s t c o n s t C c o n s t f l y () b i r d f l y () r o c k r o c k v o i d * v o i d * b i r d f l y () C v o i d * C 2. c o n s t c o n s 3. c o n s t c o n s t c o n s c o n s t C C + + c o n s t c o n s C C + +
145
146 8 C + + C C + + C C ( m a c r o ) C A L L R E T U R N C + + C C + + ( p r i v a t e ) C + + (inline function) C + + C #define f (x) (x+1) f f (1) (x) (x+1) (1) f f ( 1 ) (1 + 1) #define floor(x,b) x>=b?0:1
147 8 143 if(floor(a&0x0f,0x07)) //... if(a&0x0f>=0x07?0:1) & > = #define floor(x,b) ((x)>=(b)?0:1) > = + / - - #define band(x) (((x)>5 && (x)<10)? (x) : 0)
148 144 C + + a 4 a 5 S T D I O. H putc( ) C toupper( toupper(*p++ ) [1] C C + + class X { int i; p u b l i c : #define val (X::i) //Error p u b l i c 8.2 C + + C + + [1] Andraw Koenig C A d d i s i o n - We s l e y, 1989
149 8 145 i n l i n e inline int PlusOne(int x); inline int PlusOne(int x) { return ++x ;} + C A L L static, i n l i n e
150 146 C ( p r i v a t e ) ( p r i v a t e ) read( ) read( t h i s C A L L i ( p u b l i c ), i i i i n t f l o a t int int i ( a c c e s s o r s ) ( m u t a t o r s )
151 Wi d t h H e i g h t C Ti m e
152 148 C + +
153 8 149 C Ti m e time_t T tm local A S C I I A s c i i t i m e _ t updatelocal( ) updateascii( ) mark( ) A S C I I ascii( ) updateascii( ) ascii( ) updateascaii( C DaylightSaving( ) updatelocal( ) updatelocal( ) Ti m e 2 Ti m
154 150 C ( t h i s ) 8.3.2
155 8 151 g( ) f( g( ) g( ) f( ) f( ) g( ) 8.3.3
156 152 C + + w i t h M e m b e r s Q P S 8.4 Dan Saks in situ ( ) i n l i n e R E C TA N G L. C P P
157 8 153 i n l i n e In situ in situ 8.5 C C # #define DEBUG(X) cout<<#x " = " << X << endl #define TRACE(S) cout << #S << endl; S # S 2 S f o r for (int i = 0 ; i < 100 ; i++ ) TRACE(f(i)) ; TRACE( ) f o r FIELD( )
158 154 C assert( ) 17 _ F I L E _ _ L I N E _ assert( ) assert( ) assert( ) assert( ) #define NDEBUG A l l e g e a s s e r t allege_error( ) f a l s e
159 8 155 fprintf( ) i o s t r e a m s e x i t ( 1 ) allege( ) i f - t h e n - e l s e e x p r allege_error( ) assert( ) assert( ) assert( ) allegefile( ) allegemen( ) allege( ) A L L E G E. H //#define NDEBUG // turn off asserts allege( ) assert( ) assert( ) Print( ) 2. 3 N E S T F R N D. C P P
160 156 C + + in situ initialize( ) 3. 6 N L. C P P n l 4. A B, A B B B 5. 4 Ti m e
161 9 C + + s t a t i c C C + + s t a t i c s t a t i c C + + C 9.1 C C C + + s t a t i c 1) 2) C + + s t a t i c s t a t i c C C C + + s t a t i c
162 158 C + + static char* s o n e c h a r ( ) o n e c h a r () s o n e c h a r () 0 s t r i n g s o n e c h a r () s s static char* s=0 o n e c h a r () s i f (! s ) s 1.
163 9 159 f () X 2. main() C e x i t () m a i n ( e x i t () e x i t ( C a b o r t () C a t e x i t () m a i n ( e x i t () m a i n () e x i t () a t e x i t () m a i n ()
164 160 C + + o b j c A o b j m a i n () f o b j B g () C m a i n () f () A m a i n () B f () m a i n () g () B C g () f () o f s t r e a m o u t e x t e r n o u t C + + m a i n () m a i n () m a i n ( C s t a t i c. C P P inline function C + + C /
165 9 161 s t a t i c int a=0; a m a i n () a s t a t i c e x t e r n extern int a=0; : static int a=0; a a s t a t i c e x t e r n s t a t i c e x t e r n s t a t i c e x t e r n extern void f() void f() static void f() f () s t a t i c e x t e r n a u t o, a u t o r e g i s t e r r e g i s t e r r e g i s t e r 9.2 s t a t i c t y p e d e f C + + c l a s s, s t r u c t, e n u m u n i o n,
166 162 C + + n a m e s p a c e n a m e s p a c e c l a s s s t r u c t u n i o n e n u m 1) namespace 2) n a m e s p a c e 3) n a m e s p a c e 4) n a m e s p a c e 5) 1. n a m e s p a c e
167 friend s t a t i c y o u () m e u s i n g 1.
168 164 C using using u s i n g n a m e s p a c e using using m a t h u s i n g using u s i n g u s i n g using
169 9 165 u s i n g u s i n g u s i n g 3. using u s i n g u s i n u s i n g u s i n g u s i n g u s i n g u s i n u s i n g
170 166 C + + u s i n g using u s i n g 9.3 C++ C p u b l i c p r i v a t e p r o t e c t e d int A::i=1;
171 9 167 int i=1; i A :: i = w i t h S t a t i c :: w i t h S t a t i c 1.
172 168 C enum hack e n u m 9.3.2
173 t h i s t h i s t h i s s t a t i c
174 170 C + + t h i s t h i s m a i n () e g g e g g
175 9 171 E 9.4 out o o f o u t o u t m a i n () ARM [1] [1] The Annotated C++ Reference Manual,Bjarne Stroustrup M a rgaret Ellis 1990 p p
176 172 C + + fstream out y x 1 y 2 x, y 1 x 2 1) 2) 3) Jerry Schwarz i o s t r e a m c i n, c o u t c e r r
177 9 173 x y initializer init s t a t i c x y i n i t _ c o u n t i n i t D E P E N D. H i n i t _ c o u n t ~ i n i t i a l i z e r ()
178 174 C + + i n i t i a l i z e r i n i t i a l i z e r () C + + n e w d e l e t e C + + C float f(int a,char b); C + + _ f _ i n t _ i n t C _ f C + + f C + + e x t e r n e x t e r n extern "C" float f(int a,char b); f () C C + + C + + C C + C + + C C s t a t i c C + + s t a t i c
179 9 175 const int static int i n l i n e i n l i n p r i n t () 2. STAT D E S T. C P P m a i n () f () g () 3. S TAT D E S T. C P P o u t e x t e r n A o b j o u t 4. e x i t () 5. 7 V O L AT I L E. C P P c o m m :: i s r ()
180
181 1 0 C + + P a s c a l C + + A l g o l C C C + + C + + ( c o p y - c o n s t r u c t o r ) ( & ) C + + ( p o i n t e r- t o - m e m b e r ) 10.1 C++ C C + + C + + v o i d * C v o i d * bird* b; rock* r; void* v; v = r; b = v; C C C++ (&) int x; int & r = x; int & q = 12; 12 int x=0; int & a = x; a + + ; a x
182 ) 2) ) N U L L f( ) g ( ) 1. R E F R N C E. C P P g ( )
183 178 C + + f ( 1 ) i n t 1 2. C void f (int**); int I = 47; int* ip = &I; f (&ip); C
184 C + + X ( X &) X X C int f (int x, char c); int g = f (a,b); c h a r i n t f l o a t d o u b l e f ( ) push b push a call f ( ) add sp,4 mov g, register a b a _ b _ a g f( ) n a m e - m a n g l i n g a C P U C C + + add sp,4 f( ) 1.
185 180 C + + h e l p e r m a i n () b i g f u n ( B B h e l p e r PA S S T R U C. C P P B 2 2. C A L L C P U R E T U R N C A L L (function frame) 3. C C + + I S R I S
186 I S R v o i d C P U I S R R E T U R N R E T U R N I S R C C + + C + PA S S T R U C. C C P main( ) bigfun( ) B 2 bigfun( ) 4. b i t c o p y C C ( s t a t i c )
187 182 C + + h o w m a n y i n t print( ) h 1 f( ) 2 h 2 0 f( ) h C C++ howmany f( ) o b j e c t _ c o u n t o b j e c t _ c o u n t 0 h 2 h h 2 o b j e c t _ c o u n t
188 howmany h2 = f(h); h 2 f( ) b i t c o p y h o w m a n y ( b i t c o p y ) X ( X &) X ( b i t c o p y ) HO W M A N Y. C P P
189 184 C + + i d C strncpy( ) i d strncpy( ) h o w m a n y 2 ( h o w m a n y 2 &) i d i d c o p y C strncat( ) i d print( ) print( i d s t a t i c main( ) f( ) C
190 i o s t r e a m s s t r s t r e a m i f s t r e a m ofstream, ofstream getline( ) s t r s t r e a m 2 2 L I N E N U M. C P P H O W M A N Y 2. O U T
191 186 C + + h 1 f( ) f( h h 2 8 f( ) h h 2 h f( ) 9 h 2 h f( ) 3 h 13 f( ) 2 h h2 h 2 h 15 f ( h ) t h i s f( )
192 h 2 h 0 C b i t c o p y C + + c o m p o s i t i o n
193 188 C + + w i t h C C c o m p o s i t e w i t h C C w i t h C C w i t h C C w o C C print( ) c o m p o s i t e 7 13 c o m p o s i t e w i t h C C w o C C W O C C c o m p o s i t e main( ) composite c2 = c ; c o m p o s i t e 13 w i t h C C w o C C b i t c o p y c o m p o s i t e m a i n composite::print( ) c 2. W O C C c. W O C C memberwise initialization
194 p r i v a t e f r i e n d nocc(const nocc&) c o n s t 2. i o s t r e a m s get( ) c h a r & get( ) char c; c i n. g e t ( c ) ; c o n s t c o n s t
195 190 C C + + ( p o i n t e r- t o - m e m b e r ) C + + struct simple { int a ; }; s p s o sp->a ; so.a ; i n t e g e r i p i p * *ip = 4 ; * * s i m p l e sp->*pm = 47 ; so.*pm = 47 ; - > *. p m * int simple::*pm ; int simple::*pm = &simple::a ; s i m p l e : : a & s i m p l e :: a p o i n t e r- t o - m e m b e r int (*fp)(float) ; (* f p ) i n t * struct simple2 { int f(float); } ;
196 int (simple2::*fp) (float) ; int (simple2::*fp) (float) = &simple2::f ; & fp = simple2::f ; ( p u b l i c ) t y p e d e f [ 1 ] [1] Owen Mortensen
197 192 C + + main( ) Count( ) fptr[1] = &g ; g (this->*fptr[i]) (j); t h i s 10.5 C + + C C + + c a s t C + + A l g o l P a s c a l ( r e f e r e n c e )
198 ( p r i v a t e ) c h a r & main( ) c h a r 2. c o u t 3., PA S S T R U C. C P P
199
200 11 C + + o p e r a t o r 11.1 C C 1 << 4; << 2; 11.2 o p e r a t 1) 2)
201 K += I + J ; + + = r v 11.3 C C ** i n t e g e r b y t e
202 196 C + +
203 11 197
204 198 C + +
205 a o p e r a t o r + + ( a ); a + + o p e r a t o r + + ( a, i n t ) U N A RY. C P P + + b B::perator++( ) b + + B :: o p e r a t o r + + ( i n t ) i n t U N A RY. C P P
206 200 C + +
207 11 201
208 202 C + +
209 11 203
210 204 C + +
211 11 205
212 206 C + +
213 11 207
214 208 C + +
215 = ( s e l f - a s s i g n m e n t ) + = A + = A =
216 210 C + + = U N A RY. C P P B I N A RY. C P P 1) c o n s t + - c o n s t c o n s t ( o p e r a t o r- a s s i g n m e n t + = = ( c o n s t a n t ) 2) i n t e g e r :: o p e r a t o r + i n t e g e r c o n s t 3) A = B = C c o n s t n o n c o n s t A = B = C n o n c o n s t A = B. f o o B A foo( ) n o n c o n s t 4) i n t b o o l C + + b o o l i n t t y p e d e f 5) c o n s t * t h i s int b o o l ( i t e r a t o r ) c o n s t n o n c o n s t (++A).foo( ) foo( ) A (A++).foo( ) foo( ) + + c o n s t c o n s t 1. c o n s t c o n s t + f ( A + B ) A + B f( ) c o n s t c o n s t
217 A + B (A+B).g( ) g( ) i n t e g e r c o n s t c o n s t c o n s t 2. + return integer (left.i + right.i) ; t m p t m t m p integer tmp(left.i + right.i) ; return tmp ; [ ],
218 212 C + + ( ) n e w d e l e t e - > * ( s m a r t ) - >, i t e r a t o r
219 11 213
220 214 C + + o b j f( ) g( ) o b j _ c o n t a i n e r add( ) o b j _ c o n t a i n e r o b j _ c o n t a i n e r s p f r i e n d s p ( i t e r a t o r ) 15 main( ) O C o b j S P SP->f( ) ; //Smart pointer calls SP->g( ) ; S P f( ) g( ) o b j * obj* s p :: o p e r a t o r- > >.*. F o t r a n ** C C
221 i o s t r e a m s << > >
222 216 C + + I[4] = -1 ; [ ] os << ia.i[j] ; I O S T R E A M. H ostream& operator<<(ostream&,int) i a. i [ j ] i n t i s t r e a m o s t r e a m Murry [1] = ( ) [] -> += -= /= *= ^= &= = %= >>= <<= 11.5 C + + = = foo B ; foo A = B ; A = B ; 2 A C + + A f o o = [1] Rob Murray, C++ Strategies & Tactics, Addision-We s l e y, 1993, page 47.
223 = A f o o :: o p e r a t o r = f o o :: o p e r a t o r = o p e r a t o r = = = = = = fee fum(fi) ; = B I N A RY. C P P = = int operator=(int,foo) ; // global = not allowed! = =
224 218 C + + = ( s e l f - a s s i g n m e n t ) 1.
225 = = (reference counting) 0 ( c o p y - o n - w r i t e ) 1
226 220 C + +
227 m e m b l o c k b l o c k m e m b l o c k attach( ) m e m b l o c k detach( ) 0 delete this set( ) m e m b l o c k connted::unalias( ) connted::unalias( ) m e m b l o c k :: u n a l i a s ( ) 1 b l o c k 1 C + + n e w d e l e t e C malloc( ) free( ) n e w d e l e t e new d e l e t e malloc( ) free( ) b l o c k b l o c k memblock::attach( ) = = m e m b l o c k detach( ) m e m b l o c k
228 222 C + + = detach( ) m e m b l o c k write( ) unalias( ) main( ) = main( ) C write( ) C A 2. R E F C O U N T. C P P
229 11 223
230 224 C + +
231 m e m b l o c k s t a t i c b l o c k c o u n t b l o c k n u m print( ) c o u n t e d i d c o u n t e d m e m b l o c k b l o c k m e m b l o c c o p y addname( ) i d 3. = t y p e : : o p e r a t o r = ( t y p e ) = (memberwise assignment)
232 226 C + + f o o = b a r :: o p e r a t o r = = p r i v a t e 11.6 C C + + C
233 f( ) o n e f( ) t w o one t w o t w o :: t w o ( o n e ) t w o :: t w o ( o n e ) t w o f( f( ) t w o f( ) explicit [1] t w o t w o f ( t w o ( O n e )) O n e t w o o p e r a t o r [1] e x p l i c i t
234 228 C + +
235 n u m b e r + ( f r i e n d ) - i n t i n t n u m b e r main( ) n u m b e r n u m b e r n u m b e r + i n t n u m b e r :: o p e r a t o r + i n t n u m b e r i n t + n u m b e r n u m b e r :: o p e r a t o r + n u m b e r - n u m b e r 1 - a n u m b e r 1-1 n u m b e r - C strings s t r i n g C
236 230 C + + strcmp( ) S T R I N G. H S T R I N G. H s t r i n g c h a r * c h a r * s t r i n g
237 X operator Y( ) Y X X Y ( f a n - o u t )
238 232 C + + C A B h( ) main( ) make_a( ) make_b( ) F E E F I. C P P f o fee fiddle f o f e e f e e f e e = fee fiddle = FO ; 11.7
239 private char i o s t r e a m < < > > I O S O P. C P P f s t r e a m s s t r s t r e a m s s t d i o s t r e a m s ( c i n c o u t ) * / n u m b e r int( ) 4. U N A RY. C P P B I N A RY. C P P 5. FA N O U T. C P P
240
241 1 2 C A D C malloc( ) free( ) malloc( ) C + + 1) C + + 2) 3) C + + malloc( ) free( ) C + + n e w d e l e t e 12.1 C + + 1) 2) 2 C ) 2) 3)
242 C C malloc( ) calloc( ) realloc( ) free( C malloc( )
243 236 C + + obj* Obj = (obj*)malloc(sizeof(obj)) ; malloc( ) v o i d * C + + void* malloc( ) 0 Obj->initialize( ) ; C C + + C new C + + n e w n e w n e w foo *fp = new foo(1,2) ; m a l l o c ( s i z e o f ( f o o )) 1 2 f o o t h i s f p f o o n e w n e w n e w foo *fp = new foo ;, delete n e w d e l e t e d e l e t e free( ) n e w d e l e t e delete fp ; f o o d e l e t e n e w malloc( ) calloc( ) realloc( ) d e l e t e n e w d e l e t
244 malloc( ) free( ) t r e e < < o s t r e a m f r i e n d o s t r e a m & o s t r e a m calloc( ) realloc( ) malloc( ) 1) malloc( ) 2) m a l l o c ( ) 3) malloc( ) free( )
245 238 C + + malloc( ) 12.2 n e w d e l e t e s t a s h s t a c k string s t a s h s t a c k s t a s h s t a c d e l e t e v o i d d e l e t e v o i d s t a s h s t a c k d e l e t e S t r i n g S t r i n g
246 p r i v a t e p r i v a t e = S t r i n g S t r i n g f r i e n d makestring( ) s t a t i c make( ) String::make( ) s = new char[strlen(s) +1] ; c h a r c h a r * c h a r S t r i n g i o s t r e a m i o s t r e a m St r i n g stash 5 s t a s h 5 p s t a s h 5 s t a s s t a s h n e w d e l e t e pointer stash
247 240 C + + s t o r a g e v o i d n e w malloc( ) v o i d * v o i d storage = new void*[quantity = Quantity] ; v o i d v o i d [] fetch( ) v o i d
248 add( ) inflate( ) realloc( ) n e w r e a l l o c malloc( ) realloc( ) free( ) n e w d e l e t e malloc( ) new( ) delete( ) p s t a s h s t a s h
249 242 C + + intstash.add( new int(i) ) ; s t a s h n e w new int(i) i n t i n t i p s t a s h :: o p e r a t o r [] p s t a s h v o i d 2 p s a t s h S t r i n g makestring( ) String::make( ) ( s t a t i c char* p = *(String*)stringStash[i] ; [] S t r i n g * S t r i n g c h a r * S t r i n g S t r i n g c h a r * stack s t a c k 4
250 struct link stack::push( ) n e w l i n k :: l i n k d a t a n e x t stack::push( ) l i n k l i n k head = new link(data, head) ; 4 d e l e t e free( ) s t a s h v o i d s t a c k
251 244 C + + s t a c k s t a s h S t r i n g s t a c k s t a c k s t a c k 12.3 new delete C n e w foo* fp = new foo[100] ; 100 f o o f o o * foo* fp2 = new foo ; f p f p [ 2 ] delete fp2 ; //O K delete fp ; // Not the desired eff e c t f o o f p 2 f p 99
252 delete []fp ; delete [100]fp ; f p int const* q = new int[10] ; const int* q = new int[10] ; c o n s t int int* const q = new int[10] ; q q n e w n e w - h a n d l e r 0 n e w - h a n d l e r (throw an exception) 17 n e w - h a n d l e r N E W. H set_new_handler( ) n e w - h a n d l e r
253 246 C + + new-handler v o i d w h i l e i n t n e w n e w - h a n d l e r n e w - h a n d l e r 12.5 new delete n e w n e d e l e t e d e l e t n e w d e l e t e n e w d e l e t e C + + n e w d e l e t e n e w d e l e t e C + + n e w d e l e t e n e w n e w n e w d e l e t e n e w n e 0 n e w - h a n d l e r b a d _ a l l o c 17 n e w d e l e t e new delete n e w d e l e t e
254 n e w s i z e _ t 0 0 n e w - h a n d l e r n e w v o i d * d e l e t e n e w v o i d * v o i d * d e l e t e v o i d n e w d e l e t e
255 248 C + + n e w d e l e t e C malloc( ) free( ) n e w d e l e t e printf( ) puts( ) i o s t r e a m s i o s t r e a m c i n c o u t c e r r n e w printf( ) n e w main( ) n e w d e l e t e s n e w d e l e t e new delete n e w d e l e t e s t a t i c s t a t i c n e w n e w n e w n e w d e l e t e n e w d e l e t e f r a m i s f r a m i s ( b y t e s ) ( b y t e )
256 psize f r a m i s f r a m i s p s i z e 0 0 n e w n e w n e w - h a n d l e r n e w d e l e t e i o s t r e a m s d e l e t e f r a m i s f r a m i s n e w n e d e l e t e
257 250 C + + d e l e t e 0 main( ) f r a m i s f r a m i s n e w d e l e t e new delete n e w d e l e t e new( ) delete( ) n e w [] d e l e t e []
258 n e w d e l e t e n e w d e l e t e n e w d e l e t n e w d e l e t e n e w i n t 2 20 n e w * d e l e t e d e l e t e w i d g e t n e w 4 4 delete []widget ; n e w d e l e t e foo* f = new foo ; n e w f o o f o
259 252 C + + n e w 0 0 n e w n e n e w 1) 2) n e w n e w n e w n e w s i z e _ t X* xp = new(a) X ;
260 a n e w n e w n e w n e w d e l e t e xp->x::~x( ) ; //explicit destructor call new 12.6
261 254 C + + C C + + n e w d e l e t e C + + n e w d e l e t e c o u t n e w d e l e t e n e w d e l e t e 2. p s t a s h 1 n e w 3. n e w d e l e t e 4. F R A M I S. C P P n e w d e l e t e n e w d e l e t e
262 1 3 C + + C C X
263 256 C + + p r i v a t e p u b l i c p e r m u t e () X X Y 13.2 Y Y X
264 Y X Y X X m a i n () s i z e o f ( Y s i z e o f ( X ) p u b l i c p r i v a t e p u b l i c p r i v a t e p u b l i c p u b l i c p u b l i c h a n g e () p e r m u t e () p u b l i c s e t () s e t () Y r e a d () p e r m u t e () m a i n ( Y s e t () c h a n g e () s e t ()
265 258 C C + + p r i v a t e C + + b a r f o o bar i n t foo::foo(int i) : bar(i) { // foo2:foo2(int I) : bar(i), memb(i+1) { //... foo2 bar memb C + +
266 int i(100); 13.4
267 260 C + + C B A C::f() B :: f () a. f ( C::f() C f() a. f () B :: f (
268 ofstream
269 262 C + + bart d o h () bart, milhouse operator= 11 operator=
270 operator= operator other() root other derived root f() other main() root derived operator=( ) root other root 13.5
271 264 C + + private p u b l i c Car
272 i s - a has-a ifstream ifstream strstream fname1 ifstream & ifstream fname1 main
273 266 C + + c o u t < < f i l e. r d b u f ( ) < < e n d l ; filebuf * rdbuf() {return File.rdbuf();} fname1 rdbuf() ifsream
274 ofstream fname2 fname2 o f s t r e a m stack stack S T R I N G S. H S TA C K 11.H
275 268 C + + S TA C K 11.OBJ s t r i n g l i s t stack p u s h () s t r i n g s t a c k v o i d p e e k () p o p () s t r i n g v o i d 12 s t a c k :: ~ s t a c k () d e l e t e v o i d d e l e t e v o i d s t r i n g l i s t :: ~ s t r i n g l i s t () s t r i n g d e l e t e 1) stack p r o t e c t e d s t r i n g l i s t p r o t e c t e d 2) s t a c k 3) s t r i n g s t r i n g l i s t public p r i v a t e F N A M E 2. C P P private p r i v a t e p r i v a t e p r i v a t e p r i v a t e p r i v a t e p u b l i c p r i v a t e p u b l i c
276 p r i v a t e p r i v a t e p r o t e c t e d p r i v a t e p r o t e c t e d p r i v a t e p r i v a t e C S S H A P E p r o t e c t e d
277 270 C + + p r i v a t e p u b l i c p r i v a t e p u b l i c p r o t e c t e d i s - a ofstream ofstream FNAME2.CPP ofstream fname2
278 i n s t r u m e n t w i n d i n s t r u m e n t p l a y () wind w i n d instrument t u n e () i n s t r u m e n t m a i n () t u n e () w i n d C + + w i n d i n s t r u m e n t t u n e () instrument w i n d t u n e () i n s t r u m e n t i n s t r u m e n t w i n d i n s t r u m e n t W I N D. C C P 17
279 272 C s t a c k s t r i n g l i s t s t r i n g I N H S TA C K. C P P ( ) s t a c k s t r i n g l i s t s t r i n g l i s t p r i v a t e s t r i n g l i s t
280 W I N D. C P P ( ) w i n d i n s t r u m e n t wind w; instrument * ip = &w; i p i n s t r u m e n t i p w i n d p l a y () i p - > p l a y ( m i d d l e C ) ; i n s t r u m e n t p l a y () i n s t r u m e n t p l a y () w i n d p l a y () C + + v i r t u a l C A R. C P P v e h i c l e v e h i c l e v e h i c l e c a r 2. A B A C C B C C P S TASH.H & PSTA S H. C P P p s t a s h S t r i n g P S T E S T. C P P p s t a s h 4. p r i v a t e p r o t e c t e d
281
282 1 4 C + + w h a t h o w p r i v a t e C + + C C + + C + + C C + + C + + C C + + C C + + C + + O O P 14.1
283 t u n e () i n s t r u m e n t i n s t r u m e n t m a i n () w i n d t u n e () instrument w i n d w i n d i n s t r u m e n t w i n d i n s t r u m e n t w i n d i n s t r u m e n t 14.2 W I N D 2. C P P i n s t r u m e n t :: p l a y
284 276 C + + w i n d i n s t r u m e n t w i n d :: p l a y i n s t r u m e n t p l a y C W I N D 2. C P P b i n d i n g C i n s t r u m e n t 14.3 C + + v i r t u a l v i r t u a l v i r t u a l v i r t u a l v i r t u a v i r t u a l v i r t u a v i r t u a l W I N D 2. C P P p l a y () v i r t u a l
285 w i n d :: p l a y v i r t u a l W I N D 2. C P P play( ) v i r t u a l t u n e () O O P t u n e () i n s t r u m e n t t u n e ()
286 278 C + +
287 w i n d v i r t u a l a d j u s t () b r a s s w o o d w i n d A [] instrument f () t u n e () v i r t u a l C + + C 14.4 C++ C + + v i r t u a l b r a s s i n s t r u m e n t p l a y ()
288 280 C + + V TA B L E V TA B L E v p o i n t e r V P T R V TA B L E V P T R V TA B L E V TA B L E V P T R
289 i n t o n e _ v i r t u a l n o _ v i r t u a l v o i d V P T R one_virtual t w o _ v i r t u a l s V P T R C + + v i r t u a l int a W I N D 4. C P P A [] i n s t r u m e n t instrument w i n d p e r c u s s i o n s t r i n g b r a s s i n s t r u m e n t i n s t r u m e n t 14-1 i n s t r u m e n t v i r t u a l V TA B L E v i r t u a l v i r t u a b r a s s V TA B L E a d j u s t V P T R S I Z E S. C P P V P T R V P T R V TA B L E V P T R V TA B L E C A L L i n s t r u m e n t b r a s s a d j u s t ()
290 282 C + + i n s t r u m e n t i n s t r u m e n t i n s t r u m e n t i n s t r u m e n t V P T R V P T R V P T R V TA B L E V TA B L E 14-2 p l a y () w h a t () a d j u s t () a d j u s t () V P T R + 2 i n s t r u m e n t :: a d j u s t V P T R + 2 V P T R f i n s t r u m e n t & i i. a d j u s t ( 1 ) ; C + + C 1 s i intel x86 i t h i s t h i s s t a t i c t h i s V P T R V TA B L E V P T R t h i s V P T R mov bx word ptr[si] s i t h i s V P T R V P T R b x b x V P T R V TA B L E V TA B L 0 V P T R a d j u s t () V TA B L E V TA B L E call word ptr [bx+4]
291 C C vpointer V P T R V P T V TA B L E V P T R W I N D W I N D V P T R i n s t r u m e n t i n s t r u m e n t V P T R C + + b 1 - > f () b 2. f () b 1 b 2 b a s e b 3. f () b a s e b a s
292 284 C C + + C A L L [ 1 ] C + + C C U n i x C + + [ 2 C ] C C + + C C + + V TA B L E S t r o u s t r u p v i r t u a l C + + C 10 % C + + C 14.6 i n s t r u m e n t i n s t r u m e n t i n s t r u m e n t 14-3 i n s t r u m e n t [1] Smalltalk [2] C + +
293 v i r t u a l v i r t u a l i n s t r u m e n t i n s t r u m e n t i n s t r u m e n i n s t r u m e n t C + + virtual void x() = 0; V TA B L E V TA B L E V TA B L E WIND4.CPP 14.3
294 286 C + +
295 V TA B L E
296 288 C + + base VTA B L E 14.7 VTABLE V TA B L E V TA B L E
297 b a s e v a l u e () d e r i v e d s h i f t () v a l u e b a s e d e r i v e d V TA B L E derived VTA B L E v a l u e base VTA B L E d e r i v e d s h i f t V TA B L E d e r i v e d V TA B L E V TA B L E v a l u e d e r i v e d s h i f t V TA B L E V TA B L E ( ( d e r i v e d * ) B [ 1 ] ) - > s h i f t ( 3 ) B [ 1 ] d e r i v e d RT T I 1 8 C + + [ 1 ] 14-4 [1]
298 290 C + + c a l l () b a s e b a s e s u m () c a l l () b a s e b a s e c a l l () b a s e 14-5 b a s e c a l l b a s e b a s e d e r i v e d d e r i v e d b a s e V P T R base VTA B L E b a s e b a s e
299 V P T R V TA B L E V P T R V P T R V P T R i n l i n e C + + i n l i n e V P T R t h i s operator new class x public p r o t e c t e d
300 292 C V P T R -- V P T R V TA B L E V P T R V TA B L E V P T R V TA B L E V P T R V P T R V TA B L E V TA B L V TA B L E V TA B L E 14.9 B
301 d e l e t e n e w d e l e t e V P T R
302 294 C + + V P T R C + + c o n s t s w i t c h C + + C s h a p e s h a p e c i r c l e s q u a r e t r i a n g l e d r a w () s h a p e d r a w () 2. 1 d r a w () s h a p e d r a w () E A R LY. C P P 5. class X X class Y X X 6. 5 V P T R 7. 8.
303 1 5 (building block), S m a l l t a l k C + + C + + S m a l l t a l k S m a l l t a l k C + + C + + C C C + + s t a c k
304 296 C + +
305 i s t a c k i s t a c k I t e r i s t a c k i s t a c k I t e r i s t a c k i s t a c k i s t a c k I t e r i s t a c k i s t a c k I t e r + + f i b o n a c c i m a i n () n e w d e l e t e C A D C n e w d e l e t e h u g e m a l l o c () f r e e (), h u g e C + + n e w n e w 15.2 i s t a c k
306 298 C + + C C + + S m a l l t a l k C C C s t a c k Smalltalk S m a l l t a l k o b j e c t S m a l l t a l k S m a l l t a l k S m a l l t a l k S m a l l t a l k S m a l l t a l k o b j e c t S m a l l t a l k S m a l l t a l k o b j e c t o b j e c t O O P o b j e c t o b j e c t S m a l l t a l k C + + C C + + S m a l l t a l k [1] C + + S m a l l t a l k C + + o b j e c t C o b j e c t C + + S m a l l t a l k o b j e c t Object [1] OOPS Keith Gorlen N I H
307 o s h a p e s h a p e o b j e c t C + + C + + C + + S m a l l t a l k o b j e c t [ 1 ] o b j e c t [2] S t r o u s t r u p S m a l l t a l k S t r o u s t r u p C + + [3] 15-3 o b j e c t C t e m p l a t e [1] AT & T [2] The C++Programming Language Bjarne Stroustrup A d d i s i o n - We s l e y, 1986 [3] A D A
308 300 C + + : template<class T> T a r r a y o p e r a t o r [] C a s s e r t () a s s e r t () a l l e g e () 17 m a i n ( ) array<int> ia; array<float> fa; a r r a y _ i n t a r r a y _ f l o a t i a f a
309 a r r a y < T > t e m p l a t e < > Windows DLL C P P (the stack as a template) I S TA C K. C P P ( )
310 302 C + + stackt<t>& S p u s h () s t a c k t T
311 i s i t
312 304 C + + m b l o c k 17 a s s e r t () h o l d e r m b l o c k h o l d e r m b l o c k m b l o c k h o l d e r 15.4 stash & stack s t a s h s t a c k
313 C stash s t a s h, ( 12 )
314 306 C + +
315 15 307
316 308 C + + enum owns s t o r a g e t s t a s h S O RTED.CPP ( ) o w n o w n s () t s t a s h I t e r forward() b a c k w a r d () r e m o v e () t s t a s h I n t 12 S t r i n g
317 15 309
318 310 C stack 13 s t a c k
319 15 311
320 312 C + + t s t a s h O w n s () t s t a c k I t e r a t o r c u r r e n t () 11 operator int() C P P t s t a c k S t r i n g
321 s t a c k t s t a c S S t r i n g
322 314 C + + typedef Hstring t y p e d e f = n e w d e l e t e = s t r i c m p () C i n t e g e r i n t
323 t s t a s h o p e r a t o r [] o p e r a t o r [] =
324 316 C + +
325 e x p a n d () e x p a n d () T **& r e a l l o c () s i z e index delete size int& o p e r a t o r [ ]
326 318 C + + C s t r t o k () St r i n g w o r d s
327 a d d ( ) c o n t a i n s ( ) i n d e x () o p e r a t o r [] l e n g t h ( ) i n d e x () c o n t a i n s () w i t h i n ( )
328 320 C + + strtok() a d d () c h a r * S S t r i n g < 40 > c h a r * a d d () a d d () a d d () n e w
329 o p e r a t o r = o p e r a t o r [] in_value() o u t _ v a l u e ()
330 322 C + + b u i l t - i n S S t r i n g
331 strcount[s]++;//count word s c h a r * o p e r a t o r [] S S t r i n g < 80 > S S t r i n g < 80 > ( c h a r *) o p e r a t o r [] o p e r a t o r [] i n t e g e r & a s s o c _ a r r a y C i s s p a c e () shoplist[&buf[i]] +=count; c h a r * S S t r i n g 15.7 t s t a s h
332 324 C + +
333 o p e r a t o r ( ) u r a n d m a p m a p m a s o r t e d > S S t r i n g i n t e g e r i n t () >
334 326 C + + i n t e g e r t s t a s h s t o r a g e s o r t e d t s t a s h s o r t e d t s t a s h s o r t e d S e t s o r t e d S e s e t s e s o r t e d C + + S O RT E D. H SString i n t e rg e r s o r t e d a d d ()
335 ) 2) 3) C I N H S TA K. C P P ( ) s t a c k
336 328 C + + ( ) ( RTTI)
337 15 329
338 330 C + +
339 t s t a c k t r a s h t r a s h t s t a c k t r a s h p u s h () t r a s h tally s o r t e r t r a s h b i n 15.9 C + + S T L standard template library S T L A S T L S T L (associative container) S T L
340 332 C + + S T L S T L S T L S T L S T S T L S T L C + + [ 1 ] m a l l o c () c a l l o c () r e a l l o c () [1] C++Inside & out(osborne/mcgraw-hill, 1993)
341 r e a l l o c ( ) ) getmem() g e t m e m ()
342 334 C + + typedef cntr o l d m e m o l d m e m g e t m e m () g e t m e m () f r e e m e m g e t m e m () o l d m e m f r e e () g e t m e m () c n t r o l d m e m T * c n t r * f r e e () free(&(((cntr*) oldmem )[-1])); g e t m e m () c n t r r e a l l o c () m e m s e t () o l d m e m o l d m e m = ( T * ) & ( ( ( c n t r * ) m ) [ 1 ] ) ; o l d m e m g e t m e m () g e t m e m ()
343 g e t m e m ( ) g e t m e m () void* & o l d m e m v o i d * tstack t s t a c k t s t a c t s t a c k
344 336 C + +
345 a p p l i s t ( ) a p p l i s t ( ) 10 a p p l i s t () a p p l i s t ( ) [ 1 g r o m i t ] a p p l i s t () t s t a c k t s t a c a p p l i s t (), d o g s. a p p l i s t ( & g r o m i t : : s i t ) ; [ 2 2 ] template class bobbin<thread>; template void sort<char>(char *[]); S O RT E D. C P P [1] Nick Park [2]
346 338 C + + s o r t e d c h a r * c h a r * s o r t e d
347 b u b b l e s o r t () s t r c m p ( > O O P C [ 1 ] C tstack t s t a c k I t e r a t o r s h a p e t s t a c k s h a p e S S H A P E 2. C P P t s t a c k 3. R E C Y C L E. C P P t s t a s h t s t a c k 4. S E T T E S T. C P P s o r t e d S e t s e t. 5. tstash A P P L I S T. C P P 6. T S TA C K. H A P P L I S T. C P P t s t a c k 7. t s t a c k a d d () a d d () 8. t s t a c k 9. S O RT E D. C P P u r a n d S O RT E D. C P P 10. G E T M E M. H typedef cntr 11. S S t r i n g [1] C++
348
349 1 6 M I multiple inheritance) M I M I 16.1 C + + S m a l l t a l k S m a l l t a l k S m a l l t a l k, C + + C + + C S m a l l t a l k O b j e c t S m a l l t a l k S m a l l t a l k S m a l l t a l k Smalltalk class S m a l l t a l k O b j e c t C + + C + + M I C + + AT&T cfront2.0 M I M I M I M I v o i d * pstash s t a c k S m a l l t a l k O b j e c t s O b j e c t S m a l l t a l k S m a l l t a l k O b j e c t O b j e c t s 16-1 C + + A h o l d e r B B i t I m a g e B i t I m a g e h o l d e r B i t I m a g e h o l d e M I 15 M I
350 M I M I M I d 1 d 2 m i m i d 1 d 2 m i d 1 d 2 b a s e d 1 d 2 b a s e m i 16.3 m i b a s e b a s e?
351 342 C + + d 1 d 2 v f () m i b [] new mi b a s e * d 1 b a s e d 2 b a s e 16.4 m i v f () v i r t u a l v i r t u a l p o i n t e r m a g i c
352 m i v f () m o s t - d e r i v e d b a s e d 1 d 1 m i m
353 344 C + + d 1 d 2 b a s e m i x b a s e d 1 b a s e d 2
354 ,
355 346 C pointer magic
356 core size s i z e o f ( b ) = 2 s i z e o f ( n o n v _ i n h e r i t a n c e ) = 2 sizeof (v_inheritance)=6 s i z e o f ( M I ) = 1 2 b n o n v _ i n h e r i t a n c e V P T R V P T R [ 1 ] 16.6 t h i s t h i s [1] Jan Gray C++Under the Hood, a chapter in Black Belt C++(edited by Bruce Eckel, M& T press, 1995)
357 348 C + + t h i s m i t h i s m i sizeof(mi)=40 hex mi this=0x223e base1 this=0x223e
358 base2 this=0x224e member1 this=0x225e member2 this=0x226e base 1 pointer=0x223e base 2 pointer=0x224e C + + b a s e 1 b a s e 2 t h i s 1) 2) 3) 4) s e r i a l i z a t i o n d e s e r i a l i z a t i o n serialize() 1. M I p e r s i s e n c e
359 350 C + +
360 persistent::read() p e r s i s t e n t :: w r i t e () t h i s read() write() I O w r i t e () 18 s i z e o f d a t a V P T R w d a t a 1 m a i n () F 1. D AT p e r s i s t e n t w d a t a 2 p e r s i s t e n t t h i s t h i s t h i s [ 1 ] [1]
361 352 C + +
362 16 353
363 354 C + + p e r s i s t e n t d a t a d a t a p r o t e c t e d w d a t a 1 w d a t a 2 I O d a t a w r i t e () c o n g l o m e r a t e d a t a w d a t a 1 w d a t a 2 p e r s i s t e n t V P T R w r i t e () r e a d () r e a d () w r i t e () r e a d () w r i t e () c h a r * r e a d () r e a d () w r i t e () read() w r i t e ( ) C MI P E R S I S T 2. C P P d a t a read() w r i t e () d a t a w d a t a 1 w d a t a 2 M I 1) 2)
364 M I 16.8 A () B ()
365 356 C + + V E N D O R. L I B V E N D O R. O B J
366 f () A () B ()
367 358 C + + m y b a s e ( M I ), f () g ( M I paste1::v() p a s t e 1 :: f () m a i n ( m y b a s e mybase * mp=plp;// upcast d e l e t e m p g () m p A () B () v () 16.9 C + + O O P O O C + + S m a l l t a l k C + + M I
368 Zack Urlocker g o t o g o t o M I C + + O c c a m O c c a m s Razor M I i n t v o i d f () X X Y Z Y Z i n t Y Z A A f () 2. X p x A p x X A X 3. f () p x f ()
369
370 1 7, printf( ) C C + + 1) 2) C C + + t r y t h r o w c a t c h C C 8 C assert( ) 8 assert( #define NDEBUG assert( ) allege( ) 8 allege( ) C 1) C errno( ) perror( )
371 ) C s i g n a l () r a i s e () 3) C setjmp( ) longjmp( ) setjmp( ) longjmp( ) setjmp( ) C + + C s e t j m p / l o n g j m p s e t j m p / l o n g j m p s e t j m p ( ) j m p _ b u f j m p _ b u f l o n g j m p () s e t j m p () s e t j m p () l o n g j m p () l o n g j m p ()
372 362 C + + j m p _ b u f g o t o s e t j m p / l o n g j m p [1] C++ longjmp() C throw myerror ("something bad happened"); m y e r r o r t h r o w t h r o t h r o w 17.3 C try t r y try { } // code that may generate exceptions [1] C + + longjmp( )
373 t r y c a t c h c a t c h i d 1 id2 c a t c h c a t c h s w i t c h c a s e b r e a k C + + C ++ w h i l e
374 364 C C + + t h r o w t h r o void f ( ) throw ( toobig, toosmall, divzero) void f ( ); void f ( ) throw ( ); 1. unexpected( ) unexpected( ) 2. set_unexpected( ) unexpected( ) set_new_handler( ) set_unexpected( ) set_unexpected( ) v o i d u n e x p e c t e d unexpected( ) set_unexpected( ) E X C E P T. H
375 up f i t f( ) up f i t g( ) v e r s i o n 1 f( ) g( ) v e r s i o n 1 g( ) v e r s i o n 2 g( ) v e r s i o n 2 f( ) g( f( ) f( ) my_unexpected( ) unexpected( ) unexpected( ) exit( ) abort( ) unexpected( ) u n e x c e p t e d u n e x c e p t e d new_handler( ) unexpected( ) terminate( ) unexpected( ) f o r
376 366 C + + f o r, while, do if f( ) u p f i t f( ) g( ) v e r s i o n 2 my_unexpected( ) set_unexcepted( ) unexcepted( ) void f ( ) void f ( ) throw (...) // not in C++ void f ( ) (á la C) catch (... ) { } cout << "an exception was thrown" <<endl; t h r o w catch (...) { } cout << "an exception was thrown "<<endl; t h r o w ;
377 c a t c h terminate( ) terminate( ) unexception( C abort( ) abort( ) main( ) (catch(...)) 2. set_terminate( ) set_ terminate( ) terminate( ) set_ terminate( ) terminate( ) terminate( ) v o i d terminate( ) terminate( ) unexpected( ) terminate( ) set_ terminate( ) set_ terminate( ) terminate( ) t e r m i n a t e ( )
378 368 C + + o l d _ t e r m i n a t e o l d _ t e r m i n a t e set_ terminate( ) b o t c h f( ) terminate( ) c a t c h (... terminate( ) b o t c h terminate( ) 17.4 C + + unexpected( )
379 17 369
380 370 C + + n o i s y n o i s i o b j n u m n a m e C strncpy( ) z unexpected( ) new d e l e t e unexpected_rethrow( ) main( ) unexpected( ) n o i s y n 2
381 ~ 4 n e w d e l e t e d e l e t n e w 12 d e l e t e n 1 n 2 unexpected_rethrow( ) n 3 n 4 unexpection( ) unexpected_rethrow( ) unexpected_rethrow( ) n 4 n 3 unexpected_rethrow( ) 17.5
382 372 C + + u s e R e s o u r c e s b o n k og::operator new u s e R e s o u r c e s u s e R e s o u r c e s b o n k
383 17 373
384 374 C + + u s e R e s o u r c e s p w r a p o p e r a t o r [] r a n g e E r r o r o p e r a t o r [] o p e r a t o r [] 0 r a n g e E r r o r o g b o n k
385 e x c e p t 1 e x c e p t 2 e x c e p t 1
386 376 C + + t r o u b l e t r o u b l e s m a l l b i g t r o u b l e 17.7 C + + e x c e p t i o n l o g i c _ e r r o r u n t i m e _ e r r o r C + + w h a t () e x c e p t i o n e x c e p t i o n I / O i o s :: f a i l u r e e x c e p t i o n d o m a i n _ e r r o r i n v a l i d _ a rg u m e n t l e n g t h _ e r r o r o u t _ o f _ r a n g e b a d _ c a s t b a d _ t y p e i d l o g i c _ e r r o r N P O S N P O size_t d y n a m i c _ c a s t 18 t y p e i d (* p ) P 18 r u n t i m e _ e r r o r r a n g e _ e r r o r o v e r f l o w _ e r r o r b a d _ a l l o c
387 C C s i g n a l () 2. C + + C s w i t c h 4. a s s e r t () a b o r t () 5. t r y c a t c h ( ) t r y
388 378 C ) 2) 3) 4) 5) 6) 7) C 8) 9) 1. u n e x p e c t () u n e x p e c t e d () 2. C + + e x p e c t i o n e x p e c t i o n w h a t () C
389 17 379, b a s e ( ) b a s e
390 380 C ) 2) C C C t e r m i n a t e () t r y W R A P P E D. C P P C + + C )
391 c h a r * t r y 2) 12 s t a s h o p e r a t o r [] o u t - o f - r a n g e 3) m a i n () 4) n e w t r y c a t c h w h i l e 5) t e r m i n a t e () 6) 7) 8)
392
393 1 8 Run-time type identification, RT T I C + + C + + RT T I C + + RT T I 18.1 shape s h a p e c i r c l e s q u a r e t r i a n g l e s h a p e r h o m b o i d s h a p e d r a w () s h a p e d r a w () d r a w () s h a p e () ( c i r c l e s q u a r e t r i a n g l e ) s h a p e * 18.2 RTTI 18-1 Tu r n C o l o r I f Yo u A r e A () s h a p e :: c i r c l e s h a p e : : s q u a r e s h a p e : : t r i a n g l e i s A () type Of() RT T I t r i a n g l e
394 C + + RT T I C + + RT T I RT T I RTTI RT T I s i z e o f () t y p e i d () t y p e i n f o = = = n a m e () t y p e i d () s h a p e * s h a p e s s h a p e *, cout << typeid(*s).name()<<endl; s b e f o r e ( t y p e i n f o &) t y p e i n f o t y p e i n f o t r u e f a l s e if(typeid(me).before(typeid(you))) //... m e y o u RT T I c i r c l e * s h a p e * s h a p e c i r c l e * c i r c l e s h a p e * s h a p e * c i r c l e * C C + + s t a t i c _ c a s t, c i r c l e * c i r c l e RT T I s h a p e * c i r c l e *( ) n u l l c i r c l e * C + + RT T I d y n a m i c _ c a s t s h a p e
395 384 C + + s h a p e
396 18 385
397 386 C + + RT T I 18.3 RT T I typeid() t y p e i d () t r u e t y p e i d ( )
398 t y p e i n f o : : n a m e ( ) o n e : : n e s t e d typeid( ) t y p e i d ( ) RT T I
399 388 C + + m i 2 m i m i 2 D 2 m i 2 d 1 d y n a m i c _ c a s t t y p e i d () t y p e i d ( typeinfo t r u e t y p e i d () d y n a m i c _ c a s t D 2 D void v o i d v o i d * RTTI RT T I
400 T Y P E I N F O. H t y p e i d () t y p e i n f o RT T I X 18.4 C + + RT T I
401 390 C + + t y p e i d ( ) t y p e i d ( ) t y p e i d () C + + b a d - c a s t D 1 X x r t y p e i d () C + + b a d - t y p e i d : t y p e i d 18.5 RT T I v i r t u a l
402 v i r t u a l t y p e i d () 18.6 RTTI RT T I s w i t c h RT T I C + + RT T I RT T I s w i t c h W I N D S. C P P i n s t r u m e n t
403 392 C + + C l e a r S p i t v a l v e () p e r c u s s i o n e l e c t r o n i c RT T I w i n d RT T I RT T I 15 trash recycling RT T I
404 18 393
405 394 C + + RT T I 15 RT T I C + + RT T I 18.7 RTTI RT T I V TA B L E t y p e i n f o t y p e i n f t y p e i d () V P T R t y p e i n f o t y p e i n f o d y n a m i c _ c a s t < * > < > RT T I * RT T I * *
406 t y p e i d ( ) 18.8 RTTI RT T I RT T RT T I C + + RT T I C + + RT T I RT T I d y n a c a s t () d y n a m i c _ t y p e ()
407 396 C + +
408 t y p e I D d y n a m i c _ t y p e () t y p e I D d y n a c a s t () s e c u r i t y t y p e I D b a s e I D b a s e I D e n u m p r o t e c t e d enum baseid s e c u r i t y I D I D I I D I p r o t e c t e d RT T I m e t a l c o m m o d i t y c o m m o d i t y s p e c i a l () m e t a l s p e c i a l () d y n a m i c _ t y p e () m e t a l c o m m o d i t y RT T I d y n a c a s t () d y n a m i c _ t y p e () t y p e I D d y n a m i c _ t y p e () t y p e I D
409 398 C + + d y n a m i c _ t y p e () d y n a m i c _ t y p e ( I D d y n a m i c _ t y p e () d y n a m i c _ t y p e () 1 ( t r u e ) d y n a c a s t () s e c u r i t y f a l s e, d y n a c a s t () C + + d y n a m i c _ c a s t C + + d y n a m i c _ c a s t D Y N A M I C - C A S T 18.9 [ 1 ] C v o i d C + + d y n a m i c _ c a s t ( ) c o n s t _ c a s t s t a t i c _ c a s t r e i n t e r p r e t _ c a s t n e w t y p e s t a t i c _ c a s t c o n s t _ c a s t d y n a m i c _ c a s t r e i n t e r p r e t _ c a s t c o n s t v o l a t i l e [1] Josée Lajoie The new cast notation and the bool data type C p p
410 static_cast s t a t i c _ c a s t s t a t i c _ c a s t v o i d *
411 400 C C i n t l o n g f l o a t i n s t a t i c _ c a s t 2 i n t l o n g f l o a t C + + v o i d * C 3 s t a t i c _ c a s t 4 s t a t i c _ c a s t d y n a m i c _ c a s t 5 s t a t i c _ c a s t d y n a m i c _ c a s t const_cast const c o n s t v o l a t i l e v o l a t i l e c o n s t _ c a s t c o n s t _ c a s t
412 c o n s t c o n s c o n s t c o n s t _ c a s v o l a t i l e c o n s t X * t h i s c o n s t _ c a s t m u t a b l e c o n s t reinterpret_cast c o n s t _ c a s t r e i n t e r p r e t _ c a s t r e i n t e r p r e t _ c a s t C r e i n t e r p r e t _ c a s t
413 402 C + + X m a i n () X r e i n t e r p r e t _ c a s t i n t * i n t * [1] V P T R x p [ 0 ] x p [ 1 ], V P T R V P T R l o n g ( r e i n t e r p r e t _ c a s t ) V P T R i n t * [1]
414 r e i n t e r p r e t _ c a s t RT T I RT T I RT T I 1) 2) 3) RT T I 4) RT T I C + + RT T I C RT T I t y p e i d () 2. RT T I Tu r n C o l o r I f Yo u A r e A () W I N D 5. C P P i n s t r u m e n t w i n d C l e a r S p i t Va l v e () w i n d t s t a s h i n s t r u m e n t n e w i n s t r u m e n t RT T I w i n d C l e a r S p i t Va l v e () i n s t r u m e n t C l e a r S p i t Va l v e ()
415
416 A C + + A.1 bool true false [ 1 ] t y p e d e f t y p e d e f t y p e d e i n t i n t b o o l b o o l t r u e 1 f a l s e ( 0 ) & & < > <= >= ==!= if,for w h i l e, d o b o o l b o o l b o o b o o l b o o l?: b o o l i n t i n b o o l + + t r u e e n u m bool i n t b o o l 0 ~ 1 b o o l A.2 C + + C + + I O S T R E A M. H # include <iostream> [1] Josée Lajoie "The new cast notation and the bool data type C
417 A 405 C. h C + + C A.3 C++ C + + C C C C + + I n t e r n e t B B S 6 C + + < c l i m i t s > < c f l o a t > < n e w > b a d _ a l l o c s e t _ n e w _ h a n d l e r RT T I < t y p e i n f o > t e r m i n a t e () unexpected() < e x c e p t i o n > C + + < s t d e x c e p t > < c a s s e r t > C A S S E RT. H C + +! = > < = > = t u p l e p a i r S T L S T C a p p e n d () a s s i g n () i n s e r t () r e m o v e () r e p l a c e () r e s i z e () c o p y () f i n d () r f i n d f i n d _ f i r s t _ o f () f i n d _ l a s t _ o f ( ) f i n d _ f i r s t _ n o t _ o f ( ) f i n d _ l a s t _ n o t _ o f ( ) s u b s t r ( ) c o m p a r e ( ) = + = [ ] w s t r i n g s t r i n g wstring ( < s t r i n g > C S T R I N G. H ) b a s i c _ s t r i n g s t r s t r e a m 6 < b i t s > < b i t s t r i n g > b i t s b i t _ s t r i n g b i t s b i t _ s t r i n g 5 b i t s set() reset() c o u n t () l e n g t h () t e s t () any() n o n e () t o _ u s h o r t ( t o _ u l o n g ( ) t o _ s t r i n g ( ) b i t _ s t r i n g b i t s s t r i n g b i t s b i t _ s t r i n g b i t s 0 b i t _ s t r i n g b i t s b i t _ s t r i n g b i t s b i t _ s t r i n g
418 406 C + + S T L S T L a d j a c e n t _ f i n d p r e v _ p e r m u t a t i o n b i n a r y _ s e a r c h p u s h _ h e a p c o p y r a n d o m _ s h u ff l e c o p y _ b a c k w a r d r e m o v e c o u n t r e m o v e _ c o p y c o u n t _ i f r e m o v e _ c o p y _ i f e q u a l, r e m o v e _ i f e q u a l _ r a n g e r e p l a c e f i l l r e p l a c e _ c o p y f i l l _ n r e p l a c e _ c o p y _ i f f i n d r e p l a c e _ i f f i n d _ i f r e v e r s e f o r _ e a c h r e v e r s e _ c o p y g e n e r a t e r o t a t e g e n e r a t e _ n r o t a t e _ c o p y i n c l u d e s s e a r c h i n p l a c e _ m e rg e s e t _ d i ff e r e n c e l e x i c o g r a p h i c a l _ c o m p a r e s e t _ i n t e r s e c t i o n l o w e r _ b o u n d s e t _ s y m m e t r i c _ d i ff e r e n c e m a k e _ h e a p s e t _ u n i o n m a x s o r t m a x _ e l e m e n t s o r t _ h e a p m e rg e s t a b l e _ p a r t i t i o n m i n s t a b l e _ s o r t m i n _ e l e m e n t s w a p m i s m a t c h s w a p _ r a n g e s n e x t _ p e r m u t a t i o n t r a n s f o r m n t h _ e l e m e n t u n i q u e p a r t i a l _ s o r t u n i q u e _ c o p y p a r t i a l _ s o r t _ c o p y u p p e r _ b o u n d p a r t i t i o n C + + f l o a t d o u b l e long double A.4 STL 1 5 C + + C + + STL [1] S T L S T L S T L S T L S T S T L S T L s e t s e i n t [1] Alexander Stepanov Meng Lee C + +
419 A 407 s e t i n s e r t () c o p y () s e t b e g i n () e n d () c o p y () i n t c o u t c o p y ( ) c o p y () I N T S E T. C P P 15 H s t r i n g i n t s t r t o k () I N T S E T. C P P
420 408 C + + S T L v e c t o r l i s t d e q u e s t a c k q u e u e p r i o r i t y _ q u e u e m u l t i s e t m a p m u l t i m a p / / b o o l / / / v e c t o r l i s t d e q u e l i s t d e q u e t o p (), p u s h () p o p () v e c t o r d e q u e ( h a s h ) S T L S T A.5 asm C + + C + + C + + A.6 & C C + + a n d o r n o t n o t _ e q b i t a n d a n d _ e q bit or o r _ e q x o r x o r _ e q c o m p l &&( )!! = & & = = ^ ^ = ~ 1
421 B [1] C + + Dan Saks Tom Plum C++ Programming G u i d e l i n e s Plum Hall 1991 Scott Meyers( E ffective C++ A d d i s o n - We s l e y, 1992 ) Rob Murray C++ strategies & Ta c t i c s A d d i s i o n - We s l e y, C + + C C + + C C + + C private, p u b l i c p u b l i p r i v a t e p r o t e c t e d 5. C Andrew Koenig [1] Andrew Binstock Unix Review
422 410 C is-a has-a p r o t e c t e d v i r t u a l C
423 B = = 26. = /Cheshire cat o s t r e a m o s t r e a m class ostream o s t r e a m t y p e d e f #include <iostream.h> 32. = x = x * t h i s A = B = C 33. c o n s t 34. r e t u r n
424 412 C + + return foo(i,j); foo x(i,j); return x; C S T D I O. H p r i n t f () 6 C + + C 43. C C + + C * 45. = 46. foo a=b;
425 B 413 = foo a(b); 47. C + + C 48. C a s s e r t () set_unexpected() u n e x p e c t e d () u n e x p e c t e d ( ) 53. t e r m i n a t e () 54. t e r m i n a t e () f o r f o f o r f o n e w n e w d e l e t e n e w d e l e t e n e w d e l e t e
426 414 C
427 C C.1 s h a p e s d r a w () d r a w () 14 ` V TA B L E V P T R s h a p e c i r c l e s q u a r e t r i a n g l e Coplien [1] s h a p e [1] James O.Coplien C + + A d d i s o n _ We s l e y, 1992
428 416 C++
429 C 417 s h a p e s h a p e t y p e s h a p e s h a p e s h a p e t y p e s h a p e s h a p s h a p e 3 cheshire cat s h a p e t y p e class shape p r o t e c t e d s h a p e s h a p e ( t y p e ) s h a p e S 0 C o p l i e n S S S S 0
430 418 C++ s w i t c h d r a w () s h a p e d r a w () S d r a w () s h a p e m a i n () s [] s h a p e V P T R V P T R s h a p e c i r c l e square t r i a n g l e f o r s h a p e d r a w () V P T R s h a p e d r a w d r a w () S d r a w () s h a p e t h i s S S 0 p r o t e c t e d S ) 2) t h i s t h i s S 0 C + + s h a p e d e l e t e s q u a r e
431 C 419 d e l e t e m a i n () delete s [i] S [ i ] s h a p e s h a p s q u a r e s h a p e s h a p e V P T R s h a p e V P T R s q u a r e s h a p e S d e l e t e S s q u a r e s q u a r e s q u a r e delete S S d e l e t e S delete 0 p r o t e c t e d S C.2
432 420 C++
433 C 421 e n u m p r o t e c t e d p r o t e c t e d
434 Powered by XiaoGuo s publishing Studio QQ: Website:
ebook55-13
1 3 C + + C C + + 13.1 X 256 C + + p r i v a t e p u b l i c p e r m u t e () X X Y 13.2 Y Y X 13 257 Y X Y X X m a i n () s i z e o f ( Y s i z e o f ( X ) p u b l i c p r i v a t e p u b l i c p r i
新版 明解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,
FY.DOC
高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 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
新・明解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
新版 明解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
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 ;
IO
1 C/C++ C FILE* fscanf fgets fread fprintf fputs fwrite C++ ifstream ofstream >>
_汪_文前新ok[3.1].doc
普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向
Strings
Inheritance Cheng-Chin Chiang Relationships among Classes A 類 別 使 用 B 類 別 學 生 使 用 手 機 傳 遞 訊 息 公 司 使 用 金 庫 儲 存 重 要 文 件 人 類 使 用 交 通 工 具 旅 行 A 類 別 中 有 B 類 別 汽 車 有 輪 子 三 角 形 有 三 個 頂 點 電 腦 內 有 中 央 處 理 單 元 A
CC213
: (Ken-Yi Lee), E-mail: [email protected] 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] : ,
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
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
提问袁小兵:
C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.
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 [email protected] 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,
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) (
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
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
Microsoft Word - 01.DOC
第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的
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 [email protected] 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
ebook15-C
C 1 1.1 l s ( 1 ) - i i 4. 14 - d $ l s -ldi /etc/. /etc/.. - i i 3077 drwxr-sr-x 7 bin 2048 Aug 5 20:12 /etc/./ 2 drwxr-xr-x 13 root 512 Aug 5 20:11 /etc/../ $ls -ldi /. /..... i 2 2 drwxr-xr-x 13 root
一 耀 州 青 瓷 的 裝 飾 手 法 與 紋 飾 種 類 耀 州 窯 的 裝 飾 紋 樣, 豐 富 多 變, 而 且 題 材 內 容 廣 泛, 組 合 形 式 多 樣, 圖 案 形 象 優 美, 令 人 賞 心 悅 目, 並 且 反 映 了 當 時 社 會 的 審 美 趣 味 和 理 想 裝 飾
宋 代 耀 州 青 瓷 的 紋 飾 風 格 與 意 義 曾 肅 良 英 國 萊 斯 特 大 學 博 物 館 學 博 士 國 立 台 灣 師 範 大 學 美 術 研 究 所 助 理 教 授 摘 要 中 國 的 飲 茶 之 風, 興 於 唐 而 盛 於 宋, 特 別 是 宋 代 宮 廷 禁 苑 和 地 方 官 吏 文 人 學 士 的 尚 茶 崇 茶, 以 品 茶 為 雅 尚 的 觀 念 與 作 法, 使
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
得 到 了 補 償. 對 於 武 姜 而 言, 莊 公 與 自 己 的 關 係 並 不 親 密, 而 共 叔 段 又 是 自 己 向 來 疼 愛 有 加 的 兒 子, 所 以, 對 莊 公 提 出 再 怎 麼 無 理 的 要 求, 武 姜 也 不 會 覺 得 有 什 麼 不 妥 之 處, 而 對 共
左 傳 - 鄭 伯 克 段 於 鄢 人 物 心 理 1021141 林 詩 倩 一. 緒 論 鄭 伯 克 段 於 鄢, 及 共 叔 段 之 亂, 是 魯 隱 公 元 年, 即 公 元 前 722 年, 春 秋 初 年 在 鄭 國 國 內 發 生 的 一 場 內 亂. 武 姜 成 為 武 公 夫 人 並 先 後 為 武 公 生 下 了 兩 個 兒 子, 長 子 莊 公 由 於 腳 先 出 來 造 成
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
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
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
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 ;
新・解きながら学ぶ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 --
## $%& %& ## () #) (( * (+++ () #) #) (+ (+ #) #) ( #, - #)). #))- # ( / / / 0 1 2 0 / $ # ( *. 3. 3 *..# 4 #$ 3 ( 5 ) ### 4 $ # 5, $ ## # 4 $# 5 ( %
# # $ %& $ %# ( $ # ( # $ ( $ $ ( ( % ( $ ( $ ( ( % ( % $ ( $ ( ( $ ( ( ( & ( ( ( $ ( ( % %# ( ( $ ( %# % ## $%& %& ## () #) (( * (+++ () #) #) (+ (+ #) #) ( #, - #)). #))- # ( / / / 0 1 2 0 / $ # ( *.
(\244j\257d\276\307\274\351_201508021-C.indd_70%.pdf)
1847-1852 1872 20 1 1896 8000 20 1896 1950 1 1896 1896 13 1900 1900 3 20 2 4 1910 1950 3 1911 1 2 3 4 1927 4 20 300 6 1906 1930 7 1911 5 1919 8 1914 9 1920 10 11 1902 200 6 12 1930 7 " # #! $! 14 15! "!
Microsoft PowerPoint - OPVB1基本VB.ppt
大 綱 0.VB 能 做 什 麼? CH1 VB 基 本 認 識 1.VB 歷 史 與 版 本 2.VB 環 境 簡 介 3. 即 時 運 算 視 窗 1 0.VB 能 做 什 麼? Visual Basic =>VB=> 程 式 設 計 語 言 => 設 計 程 式 設 計 你 想 要 的 功 能 的 程 式 自 動 化 資 料 庫 計 算 模 擬 遊 戲 網 路 監 控 實 驗 輔 助 自 動
プログラムの設計と実現II
UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall
epub83-1
C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C
Microsoft PowerPoint - plan08.ppt
程 序 设 计 语 言 原 理 Principle of Programming Languages 裘 宗 燕 北 京 大 学 数 学 学 院 2012.2~2012.6 8. 面 向 对 象 为 什 么 需 要 面 向 对 象? OO 语 言 的 发 展 面 向 对 象 的 基 本 概 念 封 装 和 继 承 初 始 化 和 终 结 处 理 动 态 方 法 约 束 多 重 继 承 总 结 2012
ebook10-5
Oracle 7.x RDBMS 5 Oracle S Y S S Y S T E M O r a c l e 5.1 O r a c l e R D B M S O r a c l e O r a c l e 5.2 SYS SYSTEM S Y S S Y S T E M O r a c l e S Y S V $ D B A C O N N E C T R E S O U R C E S Y
全国计算机技术与软件专业技术资格(水平)考试
全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明
untitled
MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12
Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc
電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 範 例 試 題 (C++) 試 題 編 號 :11900-920201-4 審 定 日 期 : 94 年 7 月 1 日 修 訂 日 期 : 96 年 2 月 1 日 97 年 1 月 30 日 ( 第 二 部 份 ) 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 應 檢 參 考 資 料 壹 試
Microsoft Word - CPE考生使用手冊160524.docx
大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該
ebook50-15
15 82 C / C + + Developer Studio M F C C C + + 83 C / C + + M F C D L L D L L 84 M F C MFC DLL M F C 85 MFC DLL 15.1 82 C/C++ C C + + D L L M F C M F C 84 Developer Studio S t u d i o 292 C _ c p l u s
概述
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
ebook
3 3 3.1 3.1.1 ( ) 90 3 1966 B e r n s t e i n P ( i ) R ( i ) W ( i P ( i P ( j ) 1) R( i) W( j)=φ 2) W( i) R( j)=φ 3) W( i) W( j)=φ 3.1.2 ( p r o c e s s ) 91 Wi n d o w s Process Control Bl o c k P C
ebook140-9
9 VPN VPN Novell BorderManager Windows NT PPTP V P N L A V P N V N P I n t e r n e t V P N 9.1 V P N Windows 98 Windows PPTP VPN Novell BorderManager T M I P s e c Wi n d o w s I n t e r n e t I S P I
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
<4D6963726F736F667420576F7264202D20A4D5A46CA1D0A740A4E5A5FEB6B02E646F63>
我 讀 孔 子 ( 第 六 屆 ) 征 文 比 賽 獲 獎 作 文 選 集 澳 門 人 文 科 學 學 會 主 辦 澳 門 基 金 會 教 育 暨 青 年 局 贊 助 2008 11 1 一 等 獎 ( 以 下 以 下 按 照 學 校 筆 劃 順 序 排 列 ) 將 心 比 心, 推 己 及 人 王 錦 江 ( 培 正 中 學 ) 己 所 不 欲, 勿 施 於 人 聖 人 孔 子 這 句 只 有 八
口 的 70% 连 南 县 的 瑶 族. 有 排 瑶 过 山 瑶 排 瑶 6 万 多 人 住 在 三 排 南 岗 i 雨 水 大 麦 山 大 坪 香 坪 盘 石 金 坑 8 个 乡 镇. 形 成 了 占 全 县 面 积 80% 的 聚 居 地 << 连 州 志 } 卷 八 排 瑶 志 曰 在 连 者
居 住 地 域 与 文 化 变 迁 一 一 以 广 东 瑶 族 为 例 赵 家 旺 * 中 国 是 个 多 民 族 国 家. 共 有 56 个 民 族. 其 中 少 数 民 族 有 归 个 根 据 1990 年 的 人 口 普 查. 全 国 总 人 口 11 亿 3 千 多 万 人. 汉 族 10 忆 4 千 多 万 人. 占 全 国 总 人 口 的 90% 多. 少 数 民 族 人 口 不 到 10%
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
(procedure-oriented)?? 2
1 (procedure-oriented)?? 2 (Objected-Oriented) (class)? (method)? 3 : ( 4 ???? 5 OO 1966 Kisten Nygaard Ole-Johan Dahl Simula Simula 爲 6 Smalltalk Alan Kay 1972 PARC Smalltalk Smalltalk 爲 Smalltalk 爲 Smalltalk
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
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!=
前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii
前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii C# 7 More Effective C# C# C# C# C# C# Common Language Runtime CLR just-in-time
untitled
8086/8088 CIP /. 2004.8 ISBN 7-03-014239-X.... TP313 CIP 2004 086019 16 100717 http://www.sciencep.com * 2004 8 2004 8 1 5 500 787 1092 1/16 16 1/2 391 000 1 2 ii 1 2 CAI CAI 3 To the teacher To the student
chp6.ppt
Java 软 件 设 计 基 础 6. 异 常 处 理 编 程 时 会 遇 到 如 下 三 种 错 误 : 语 法 错 误 (syntax error) 没 有 遵 循 语 言 的 规 则, 出 现 语 法 格 式 上 的 错 误, 可 被 编 译 器 发 现 并 易 于 纠 正 ; 逻 辑 错 误 (logic error) 即 我 们 常 说 的 bug, 意 指 编 写 的 代 码 在 执 行
2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d
2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,
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,,, ( ),,,,,
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
.' 6! "! 6 "'' 6 7% $! 7%/'& 人 类 非 洲 锥 虫 病 又 称 昏 睡 病 是 布 氏 锥 虫 冈 比 亚 亚 种!! 或 布 氏 锥 虫 罗 得 西 亚 种 "#$$ %! &'!!! 感 染 引 起 的 一 种 寄 生 虫 病 以 采 采 蝇! 为 传 播 ' 媒
) 文 章 编 号 '.')) 论 著!"#$%&' ' ' ' ' '!"# ' $%& ' ' '8 目 的 对 ' 例 输 入 性 非 洲 锥 虫 病 患 者 进 行 实 验 室 诊 断 与 病 原 体 鉴 定 方 法 收 集 患 者 的 临 床 发 病 与 流 行 病 学 调 查 资 料 采 集 血 样 脑 脊 液 瑞 氏 吉 氏 染 色 涂 片 后 镜 检 用 布 氏 锥 虫 表 达 位
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
Strings
Polymorphism and Virtual Functions Cheng-Chin Chiang Virtual Function Basics 多 型 (Polymorphism) 賦 予 一 個 函 數 多 種 意 涵, 存 在 於 同 一 類 別 之 內 祖 先 類 別 與 後 代 類 別 間 物 件 導 向 程 式 設 計 基 本 原 理 虛 擬 函 數 (Virtual Function)
Microsoft Word - chap10.doc
78 10. Inheritance in C++ 我 們 已 介 紹 了 物 件 導 向 程 式 的 第 一 個 主 要 特 性, 即 程 式 可 模 組 化 成 為 類 別 ( 物 件 ), 類 別 具 有 資 料 封 裝 的 特 性 接 下 來 我 們 要 介 紹 物 件 導 向 程 式 的 另 一 個 主 要 特 性, 那 就 是 類 別 具 有 繼 承 的 功 能 繼 承 就 是 重 複
科学计算的语言-FORTRAN95
科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造
( 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.
Microsoft Word - 11.doc
除 錯 技 巧 您 將 於 本 章 學 到 以 下 各 項 : 如 何 在 Visual C++ 2010 的 除 錯 工 具 控 制 下 執 行 程 式? 如 何 逐 步 地 執 行 程 式 的 敘 述? 如 何 監 看 或 改 變 程 式 中 的 變 數 值? 如 何 監 看 程 式 中 計 算 式 的 值? 何 謂 Call Stack? 何 謂 診 斷 器 (assertion)? 如 何
ebook39-6
6 first-in-first-out, FIFO L i n e a r L i s t 3-1 C h a i n 3-8 5. 5. 3 F I F O L I F O 5. 5. 6 5. 5. 6.1 [ ] q u e n e ( r e a r ) ( f r o n t 6-1a A 6-1b 6-1b D C D 6-1c a) b) c) 6-1 F I F O L I F ADT
(2) 廠 商 具 有 維 修 維 護 或 售 後 服 務 能 力 之 證 明 ;(3) 廠 商 具 有 製 造 供 應 或 承 做 能 力 之 證 明 ;(4) 具 有 相 當 人 力 之 證 明 屬 特 定 資 格 之 ㄧ 8.(3) 機 關 辦 理 預 算 金 額 為 新 台 幣 四 億 元
政 府 採 購 法 規 概 要 題 庫 最 後 更 新 日 期 :( 人 發 局 第 一 期 ) 2010/03/20 選 擇 題 : ( 答 案 ) 正 確 錯 誤 解 析 1.(3) 機 關 訂 定 招 標 文 件, 何 者 正 確?(1) 廠 商 履 行 契 約 所 必 須 具 備 之 財 務 商 業 或 技 術 資 格 條 件, 不 考 慮 廠 商 在 外 國 之 商 業 活 動 應 (2)
