You are on page 1of 170

++

J.

The ++
Programmer's HandBook
Paul J. Lucas

&
Bell Lahoratories

Prentice Hall, Englewood Cliffs, New Jersey 07632

++
v


. .

. .

1 993

32. 97
45

::.

45
++ : . . : J.,
1 993. - 1 7 6 . , .
-

ISBN 5-87 458-21 3-8


JI
, ++,
, / .
r - ++.
++ &,
.
Borland Borland ++ 3.0 3. 1 .
,
. r
++
, .
,
++.

3 2. 973

ISBN 0- 1 3- 1 1 8233- 1 (.)

1 992 &
Pulished Prentice-all, lnc .
Simon & Schuster Company
Englewood Cliffs, New Jersey 07632

I SBN 5-87458-21 3-8 (.)

J., 1 993,
,
,





++.
,
++, I
. ,
,
++.
,
,
. ,
.
m ++
,
.
,

m ,
- ++.
++ &,
.
,
orland orland ++ 3.0 3.1 .

. .
Intemational Switching Systems Division
& Bell Laoratories ,
. , - ++
3.0.
, ,
, :r

++ :

JIJi i ,
.

,
: .
!
. ..
, upJrta
24

JJl

1993


,
++ ,
, / m
.
, .

++ r,

,
. .
.
:

11

. . .

.
(" ... " )
, .
, (
, ).

...

.

, .
, .

.
++ ,
: . ,

++


r
++ , . r
, , ,
r, , "
"
. r ,
-
++ 3.0
. r
ero m : " ",
m .
,
J

& Unix System La orator ies : Unix System V-USL ++


Language System: Product Reference Manual, Release
Notes and Seleced Readings, r eleas es 2.0-3.0 b eta, U nix
P ress, 1 989- 1 99 1 .

Morr is 1. B olsk y: The Programmer' s andook, P rentic e


Hall , N ew J ers ey, 1 985.
Marg ar et . Ellis and.Bj ar ne Straus trup : The Annotated ++
Reference anual, A ddis o n -W es l ey , R e a d i ng ,
Mass ac hus etts , 1 989; second e di ti on 1 99 1 .
Bj ar ne S traus trup : The ++ Programm ing Language,
Ad dison-W esl ey, Re ading , Mass ac hus etts, 1 986; second
edition 1 99 1 .
Bj am e Straus trup : Parametrized Types for ++ , J ournal of

Object Oriented Progr ammi ng , Jan./Fe b. 1 988.

++
++
- . " "
++ , .
r, , ++
.
: .

. . .
1, 1.
.

11,
.
I 1 1.

/* .
for( 1 =; 1 < 1 0; ++1 ) / /
[ 1 ] =;
*/

. . .
,
, : -

!! Ji 11 (.
"" "") .

11

: ++

: .

1, word_count. pl2

. foo
Foo.

. . .
:: ( : .
m ++) :

asm
char

auto
class

do
float

delete

extem
if
operator

inllne
overload

register
static

retum
struct

throw

try

virtual

void

break
const
doule
for
int

case
continue
else

catch

long

default
enum
goto
new

private

protected

puiic

short
switch
typedef
volatile

sign ed

sizeof

template

this

union
while

unsigned

friend

catc h. throw try


:: . :
++ .
++ : overload.

. r.

: asm. private.
protected. signed, t emplate volat ile .

JJ (_). mr ++ n 11

12

++


fortran pascal.
asm 11 .

. . .

: ,
, , ,
.

2 3, -42 , + 1 99 1 1 1 + ,

int,
it
: , long.

. . .


.
:
U u.

: ,
7 .

2 3U , 42 u , 1 99 1 U L

027. 052, 0 3707

: ,

++

13

f F.

1 7, 2 , 77

unsigned int, :
:
unsigned int ,
unsigned 1ong.

. . .

:,
,
int.
L 1
.

2 3L, Ox2al, 1 99 1 u l

n11 ...

, , ,
r.
, .:
:.

3. 1 4 1 59, , 1 . , . 2 , 1 .602- 1 9

doule, , .
F f ( float) l.
1 ( 1ong doule) .

23F, 42f, 1 99 1 F
1 1 float
3. 1 4 1 59 L, L, 1 . 602- 1 9 1 1 1 long doue

14

++

.. .

r ,
IUI . char.

,
.

' m'. '7\ '+'

'' ASCII 6.

()


VT

BS
CR

FF
\
Oddd
Oxddd

'\0'
'\'
'\n'
'\t'
'\v'
'\'
'\r'
'\f'
'\\'
'\"
'\ddd'
'\xddd'

.rr,
.
int, .

NUL
BEL
NL (LF)

'ah' , 'M P NT'

int .
, ,
.

15

++

. . .

,
.

"m", "++", " N o way, J ose!"

stat ic cha r,
.

/0.

charflveD = " Five"; 1 1 five 5

\" .
.
\ .
\ .

char * q uote ""' " / "Diplomacy/" l s lettlng them 1


have lt you r way. "

, .

11
gr eet l ng1 " Hello world!":
greeti ng2 = " Hello " "world!":
=

. .
.

16

++

(. "" "") .

...
, ,
.

=, ++, =

sqn( * + * )

true,
, . false,
.

.
,
.
.
(,
) .
.
, .
, Q
.
.

. , ie n.

, 11 int.

++

17


+
pe+ie
-
-ie
-
-

/
ie% ie

+ie sizeof ( ) .
.
-ie sizeof ( ) .
,

.
.
.
.

.


!
el 11 2
el &&2

.
. 2 , el
false.
. 2 , el
true.

lf( && l*p ) 1 1


* 1 ;

, l*p

. . .

, , doule, + 1
, !I .

, r
. ptrdiff_t,
<stddef.h> .

, .

<,<-, > >- ,


.

18

++
.
.

!
<
<

.
.
.
.

>
>-

lnllne lnt lnrange( lnt n, lnt lawer, lnt upper)


{
return lawer <= n && n <= upper;
}

. . .
v .

, n
. :
.

; 11 = ( = ( = ));


m :. ,
v

SI

v= v ( )
v .

1 += j, = 1

19

++

v+
i
+
++v
i
pv++

++pv

iv 1;
JI. iv .
iv 1;
iv .
pv sizeof( pv );
JI.
pv .
pv sizeof( pv );

pv .
: , ++
1.

lnt 1 = 3, J, k;
J = 1++;
11 1 4, J
k = -j;
11 J = 2, k
=

=
=

3
2

char b u1{3), * buf;


*++ = '';
11 bu1{0] = '', &bu1{1]
'
'
=
*++ ;
11 = &bu 1{2 ), b u 1{2] ''
=

[ ie]

v.
,
.
, (.
" " " " ).
ie .
(+ ie).

20

++

1 1
vol d VecCopy( char to[ ] , const char from[ ] )
{
for( l nt 1 ; to[ 1 ] from[ 1 ]; ++1 );
}
=

1 1 , ,
vold PtrCopy( cha r * to, char * from )
{
whl le{ *to++ *from++ ):
}
=

,

, .
<*s)..
- ,
.
(*spe) .f.
spe->f
, .
p
sv.*
s->* (*spe). .
- ,
sv. tp
.
spe->*fp <*spe). *f .
/ ,
s::
.

s::m/

sv.
s->
sv.f

struct Polnt { l nt , ; } ;
Pol nt , , * & ;
. . > -> = 1 ;
=

l nt Polnt::*coord

&Pol nt::x;

++

a .*coord = pb->* coord

2;

21

11 . = . = 2


-ie
iel ie2_
iel

ie2

iel &ie2
iel 1 ie2
iel " ie2

.
ie1 ie2 .
.
iel ie2 .
, iel
,
, iel .
.
.
.

char letterA = ''; 1 1 : 01000001


1 1 01100010
char letterB = ' ' ;
con st char mask 20 ;
1 1 00100000
char lower = letterA 1 20; 1 1 01100001
char u pper = letterB 1 "" 20; 11 01000010
=


el ? 2 : el ,
2,
2. ,
.

l n l i ne i nt ( i nt , i nt ) { retu rn > ? : ;
el , 2

el, 2.
2.

voi d Reverse( i nt [], i nt n )


r

22

++

for( lnt 1 = , j = n-1 : i < n: ++1, --j )


{

l nt t = [ 1 ]:
[ 1 ] = [ J ]:
[ j ] = t:

}
v.

::v

l nt count:
// . . .
vold f()
{

11

i nt cou nt = : :cou nt: / /


11
/ / ...

}
sizeof
sizeof( type )

: .
type.

char buf[ 1 00 ]:
whl le( c i n . getl l n e( buf, slzeof buf - 1 ) )
cout buf:
fe( , ,

..

( type )

(.
"" "") .

type

, sizeof .

r ++ " "
"".

23

++
type

type ( )

char , * &;
long cheat ( long ) ; 11
=


( ++)
n ,IJ type
. ,
, .

.
w type [ ie ] ie
type .

.
deletepe
t ,
.
.
, delete
.
v ,
delete[ ]



w type

* n n, ++.
, n " ,
n, &. ,
dou\e ( ) n double,
int ( ) n
int; ( int ).
mallocO .
malloc() .
n ++
.

24

++
.

_new_handler,
,
void.
, .
, new
, _new_handler.
_new_handler , ,
,
_new_handler.
_new_handler ;t ,

(, ) .
,
new.

vol d MyNewHandlerO

cerr "Out of memory, sorry . . . / n " ;


1 1 . . .
*
exlt( 1 ) ; 1 1 .
...

}
_new_han d ler

&MyNewH and ler;



, ,
.
. ,
, , . "exitO" "stdlib.h " " ".

++

2S

- .

[]

. ->
sizeof

-+
++ -&

new delete
. ->*
* /%
+<< >>
< <=
>>=- !==
&

&&

11

?:

*= 1- %= +=
-= <<= >>=





,
,
, I

,
n
, , ()
,
,
,
,
,






& =: 1 =

26

++

. . .

i .

n = ( = ++ ) * ( = ++ ) ;

1.
, 1 , - 2.
,
1, - 1
.


: &&, 11, ? : , () .

long doule, doule


float, m
: ,, 1ong doule
.
, char, unsigned char, short int,
unsigned short int enum I
int, i
int, unsigned int .
, unsigned long,
unsigned long.
, long int,
- unsigned int, long int
unsigned int, unsigned int long int,
unsigned long

float doute, ++
.
. int, unsigned
int.

++

27

int .

, n long int,
, long
.
, n int.

. . .

,
( ; ) .

lang uage =++:

. . .

,
n .
goto (. "goto") .

O UTTA_H E R E : retu rn res u lt:

. . .

.
, while,
do for .

* unsigned long int.

**


, ,
.

28

++

whlle( * ++ = * q++ );

. . .

,
: .
, .
,
:, ,

: : .

{ l nt t = ; = ; = t; }

:
,

(. "
:" ":") .

. . .


") .

(. "-

b rea k;

:
while, do, for switch.
,
: .

, goto,
break, continue return .

, ++ .

, ++

29

for( l nt 1 ; 1 < 1 ; ++1 )


lf( g uess = [ 1 ] )
{
cout " Congratulatlon s!/ n " ;
b reak;
11 for
}
lf( 1 = 1 ) 1 1
cout " Sorry . . . / n " ;
=

conti n ue;

r r
while, do for.
goto ottom, :

whl le( . . . )
{
11 ...
g oto bono m ;
1 1 ...
bonom : ;
}
do
{
11 ...
goto bono m ;
11 ...
bonom: ;
}whl l e( . . . );
for( . )
{
11 ...
..

30

++

goto bottom;
11
bottom:;
}

for( lnt 1 = ; 1 < 1 ; ++1 )


{
lf( [ 1 ]
)
contlnue;//
11 . . . ...
}
===

return ;


.
, r
vid.
r
, .

goto ;

, J.temo.
(Memm )

goto FAIL;


,
.
,
:

31

u: -++

vol d ContrlvedO
{
g oto L 1 : / / . . .
l nt = : // ...
1 1
L1:
goto L2; // . . .
lnt ;
// ...
L2:

goto L:
goto L4
for(: : )
{
lnt c:

// .
// . . .

L:

l nt d = ; // ...
1 1
L4:
g oto LS: //
}

L5:

if( ) 1
else 2

,
(true), onepamopl, lf

32

++

onepamop2
-

else onepamop2 .

switch
switch( ) 11 n ()
case - 1:
case -2:
n
switch( ) 11 ()

case - 1:
case -2:
n
case -:
case -4:
n
default:
n

switch ( )
...

i f( == - 1 11
== - 2 . . . )

* J ,
J,
.

++

33

. . . ,
.

switch( n )
case 2 : case 4: case 6: case 8:
appreciate n ;
=


,
.-..

, default .
, . switch
case,
case.
switch
break.

switch( )
{
case '+' : n = +; b reak;
ca se '-' : n = - ; b reak;
case ' * ' : n = * ; b reak;
case '/': n = 1 ; b reak;
defau lt:
E rror( " Bad operator: " , );
}
1 1
1 1 r b reak

default . , ,
.
2

3-207

34

++

w h ile( )

...

label : if( )
{

goto label ;
}

do while( ) ;

...

label:
if( ) goto label ;

for
for( 1 ; 1 ; 2)
2

...

1
whi le( )
{
2
2 ;
}
. . . r, continue
,
2.
2

/ - , I .

35

++

}- ,

2.
t (
) . . J.e
uel , .

] .

36

++


++ :
.
.h, - ..

.
, :, ,
, ,
ty pedef, , inline
. ,
.
.

1 . . .

, ,
,
.
int, .



, ,
, ,
, ,
,

: "" .

++

37

I ,
.


,
*
static, .

void Dryer( i nt clothes )


{
staticc l i ng: 1 1
1 1
11 . ..
}

( )
' (,
).
.



, ,
,
; ,
, ,
extern,
.

1 1 1
int g lobal:

r n auto.
.

38

++

1 1 2
extern l nt g lo ba l : 1 1 g lobal 1 -
,
,
,

static . static ,
**
.

1 1 1
static electricity; 1 1 1

1 1 2
extern electricity: 1 1
1 1 2
i nt electricity : 1 1
electricity 1
. electricity
( 2).

. . .

:
char
usiged char

( ).
.

. static .
,
, ++
. 3 .
** static "
"" "".

++
signed char
int
unsigned int
short int
unsigned short int
long int
unsigned short int
float
doule
long doule
void

39

.
( ).
(
int).
( n
).
.
(
*
) .
.
n
.
n
.
n
.
**
.

unsigned, long short


unsigned int, long int short int .
char unsigned char
signed char, n.
n , ...
sizeof ( short ) sizeof ( int ) sizeof( long )
... long , short.
n n n , ...
sizeof ( float ) sizeof ( doule ) sizeof ( long doule )
n .

;> long long,


( ) .
** void.
void ( . "") . r,
void, ,
r .

40

++

char brol led ;


un slgn ed c heck 1 97;
lon g d l stan ce &;
=

. . .


.
.
: (
) .
,
( ) .

.

en u m { chocolate, van l l l a , strawberry } ;


1 1 chocolate = , van l l la 1 , strawberry = 2
=

e n u m Frult{ orange, cherry , ban an a } ; 1 1


en u m Cost{ perPerson 2 perCouple /*
=

Frult florld a

3 * 1 };

oran ge ; 1 1
*
11 Fru lt

enum
!I ( typedef). ++
ii, .

++

41

en u m State { start, run , stop } ;


en u m Posltlon { sta rt, m l d d le, en d } ; 1 1

(. "") .

, .

class lceCream
{
11 ..
pu b l lc :
en u m Flavor { chocolate, van l l l a , strawberry } ;
Flavor flavor;
11 . . .
};
11 ...
.

Flavor favorlte ; 1 1 ; Flavor


l ceCream homeMade;
homeMade.flavor c hocolate; 1 1
homeMade.flavor l ceCrea m : :chocolate; 1 1
=

...

,
.
,

,
[ ].
. ,
m , ++

++ . .

42

++

float vf[ 1 0];


1 1 1 0 float
l nt vvl[50 18]; 11 50 8 l nt
char *vpc[5]; 1 1 5 char

(
) ,
.
(char),
.
-


, .

, :
( ). :
, :.

char g reeti ng[ ]


i nt [5]

"Yesl master? " ; 1 1 1 3

{ 71 9 } ; 1 1 [ 3] = [4] =

lnt [ 12] = { { 1 1 2 } { 31 4 } { 5 1 } } ; 1 1 [ 312]


l nt [ 12] { 1 1 21 31 41 5 1 } ; 11 { }
l nt d [ 12] = { { 1 } { 2 } { 3 } } ; 1 1 { }
11
1 1 d[ OI1 ] d[ 1 11 ] d[211 ]
=

, - .

++

43

v = &v [ O ]

sizeof.
, .

. . .

,
(. " "
" ").
06 .

i nt 1, * i p = &i ; 1 1 i nt
i nt *ppi = &pi ; 1 1 i nt
char (*pvcXS]; 1 1 char[5]
float (*pf)(i nt); 1 1
1 1 i nt float

i n l i ne void Swa p( i nt *, i nt ""' )


{
i nt t = * ;
* = * ;
* = t;
}
11 ...
Swa p( &, & ); 11
*

, ++ ( . "") .

44

++

" void", ,
,
cost volatile.
void .
void
;
.

char , * = &;
void *v = ;
1 1
char *q = ( char * )v ; 1 1

. . .

r .

&.

.
( JII4 ,
,
r )

doue agent = 028


doue &bond = agent; 11 bond agent
11 . . .
bond / = 4.0; 1 1 agent = .007
.

* ))()paOibll ll'l .

++

45

6 .

1 1 Strl n g - , < Strln g . h>

char LastChar( const Strl ng &s )


{
retu rn s. lengthO ? s[ s. lengthO - 1 ] : /0
}
11 ...
Strlng word = " barbecue" ;
char = LastChar( word );
'

'

l n l l n e veld Swap( i nt &a ; lnt & )


{
i nt t = ;
= ;
= t;
}
11 ...
S wap( , ); 1 1


class.

. -
, 6,
.

*
, ,
const.
, .

46

++

,

(. "") . r,

, .

i . . .

,

(

eon st long douie pl = 3. 1 4 1 59265 358979 32 3846 ;


eon st l nt prl me[ ] = { 1 , 2 , 3 , 4, 5, 7, 1 1 } ;


,
. m

extern

extern eon st l nt prl me[ ] = { 1 , 2 , 3, 5, 7, 1 1 } ;


, ,
. , r,
.

ehar , ;
eon st ehar * = & ; 1 1 eonst ehar

Ji . , int *&rpi
- int.

#defme, .

ANSI .

++

47

= & ; / /
* = 'Z' ; 1 1
char *const = & : / / char
/ /
&;
1 1
* = Z ;
=

'

'

con st char *const


&;
* 'Z';

&; //
//
1 1

. . .

J
.
register,
.

reg i ster l nt 1 , *pi nt;

,
.
register .
. ,
, ,
.
- & (
, > , register
.

, ,
. r,
,
. register - ""
, , , m.

48

++

volatile . . .


r.:,
.

1 1 seriai Port - -
1 1 /
voi lati le char * const seriai Port = ( char * ) 400 ;

char = * seriai Port; / /


1 1
= * seriai Port;
//
voilatile
,

.

. . .

, ,
, .
r
, , ,

struct Ca l l
{
s hort a rea, exchange, l i ne;
e n u m{ d i rect, oper_assist } type;
e n u m{ day, even i n g , weekend } rate;

voilatife .
.

49

++

};
11 ..
*
Cal l col lect; 1 1 Cal l
.

, ,
,

. -
,
( ) .

**

Ca l l work { 708, 555, 8887 } ;


1 1 work.type d i rect, work. rate
=

day


.
, .

Cal l record[ ]
1 1
{
{ 5 1 6, 555, 8858 } , 1 1 type d i rect
{ 508, 555, 05 1 6 } , 1 1 rate day
11 ,
11
2 1 2 , 555, 5444, d i rect, weekend,
908, 555, 60 1 2 , oper_assist, d ay
};
=

- -

*
struct ( typedef) . ++
, .
**
.

so

++

, , ocv m *"'* .

.
,
.

struct Featu res


{
u n slg ned touchTone: 1 ;
u n s lg ned cai iWalt: 1 ;
u n s l g ned cai i Fwd : 1 ;
u n s lg ned: 2 ;
u n slg ned s peed D i a l : 1 ;
u n si g ned d stnctRn g : 1 ;
};

1 1

. . .

,
.
, .
,
.

* int ,
. signed
unsigned. ANSI
int. -++ .
.

.

51

++

u n lon La bor
{
l nt UAW;
char tea m sters ;
char *CWA;
};
11 ...
*
La bor day; 1 1 Labor

(
) ,
.
.

**
La bor day = { 5 } ;
11 * (> 5 - l nt
La bor l nten s i ve = { '' } ; 1 1

.

La bor record[ ] = { 3, 4, 5 } ;

, .

union ( typedef) . ++ ,
.

++.

****

static.

52

++

u n ion
{
long jekyl l[1 00];
char * hyde[ 1 00];
};
hyde[ O ] = " D r. J ekyl l " ; 1 1 jekyi i[ O ]

. . .

, !)

.
typedef,
" ".

.

typedef float G IGAWA ;


typedef con st char CHAR ;
11 ...
G I GAWATT futu re = 1 .2 1 ;
l nt MyFu nctlon( char );
11 , n char
1 1 i nt
typedef i nt ( * P FC R I ) ( char );
1/...
P FCRI myFu nction Ptr = &MyFu n ction ;

(. "") .
11 ,

++

53

class
{
11 ...
p u ic:
11 ,
11 l nt
typedef l nt ( C : : * P M FCI R I ) ( l nt ) :
11 ...
}:
11 ...
P M F C I R I : 1 1 : P M FC I R I
11
C: : P M FC I R I q: 1 1

. . .

,
, ,
.
, ,
(
void) .
: (
) , (. " "
"") , (. "
" " ") (. "") .

. . .

++ r .

54

++

1 1 doue
11 doue
d o u e Hypote n u se( doue , doue );

**

1 1 , ,
d o u e Hypoten use( douie, doue );
,
.

1 1 char,
1 1 '-'
void P ri ntLi ne( l nt length, char = '-' );

,

'\f

ANSI f() ,
r . ++ ,
. ANSI , ++ f( void ) ,
.
**
,
.

r , &, const volatile


, ,
r .
r .
const & const * & .

++

55

1 1 i nt
11 douie
1 1 int douie
d o u ie ( d o u ie, douie ) ;
i nt ( i nt, i nt ) ; 1 1
1 1 i nt,
11 ,
i nt F l u ff{ i nt, char '*' ) ;
i nt F l u ff{ i nt, i nt ); 1 1
=

( ... ) ,
,

, .

void printf{ const char *format . . . );

. . .

, .
ilie

. ,
iline,
,

, register.
,
, void,

. "stdarg.h " " " .


, inline
. inline
#define.
.

56

++

return.

l n l lne doue Hypote n u se( doue , doue )


{
retu rn sq rt( * + * ):
}
vold P rl ntli ne( reg i ster char ch )
{
for( reg lster lnt 1 = ; 1 < 80; ++1 )
cout ch ;
cout e n d l ;
}
l n l lne doue ( d o u e , d o u e )
{
retu rn > ? : ;
}
l n l lne i nt ( lnt , lnt )
{
retu rn > ? : ;
}

.
,
.

vold Peek( u n s lg ned lnt * , lnt )


{
cout << '*' << << " = " << * << ' / n ' ;

++

57

. . .

, .
: - ,
- .

11
Hypote n u se( , ):
vold ( *pfl l ) ( l nt, l nt ) &:
l nt , ;
11 ...
*
i nt m ( *pfl l , ):
11
=

,
.
:
,
r r .
, ero
, ero ,
.

ma i n( ) . . .

++.
,
.

JI , pfli int
, pfli ,
int int.
, ,
, (. "
" "") .

58

++

:
int main () { !* .. *! }

i nt m a i n( i nt argc, char *argvO ) { /* . . . * 1 }


, .
argc - . argv [ ] -
char,
. argv [0 ] - ,
:, argv [ 1 ) . . . argv [argc - 1 ] -
:.

$ mag ic hat wa n d

a rgc 3
a rg v[ O ] " magic"
arg v[ 1 ] " hat"
a rg v[2] "wa n d "
=


return (.
"exit () " "stdlib.h" "
") .
,
,
, ,

inline static .

,
. $ -
.
** main O
.

++

59

. . .

,
,
*
++ .
-
extern ""

11
extern " " i nt system( con st char * ) ;

extern " "


11
{
long atol( con st char * ) ;
i nt
atoi( const char * ) :
d o u i e atof( con st char * ) ;
};

extern "" ,

++.

* ++ ,
, .
, , - ++
, -
. ,
-, . (. :
Turo Turo/Borland ++
, -
(_) , ,
++ - . )
** ++ .

60

++

; . . .


,
.
,

(- , ) ,

(- ,
) .

. . .

.
.
:
private, potected public.
private.
Private ,
-
(. " ") .
Protected ,

: (. " :" ) .
Public ,
.

(. ""
"") .

++ protected.

61

++

class Phone
{
i nt a rea , exchange, l i ne; 1 1 private
protecte d :
en u m H ookState { o n H ook, offHook } ha n d set;
p u ic:
Phone( i nt , i nt , i nt 1 )
{
a rea , exchnge , l i ne 1 ;
hand set o n H ook;
}
i nt OffH ookO const { retu rn han set
offHook; }
void G iveDai iToneQ;
long AcceptD ig ltsO:
void Ri ngQ const;
}:
=

1 1
P hone home( 5 1 6, 555, 8858 ):

pyroro .

, .

++
, .

62

++

class O uterShell
{
i nt ;
p u ic:
i nt ;
class l n nerSelf
{
l nt l a ;
p u ic:
l nt l b ;
vold Vag ue( O uterShel l & , i nt n )
{
= n ; 1 1 : ?
. = n ; 11 : - prlvate
. = n ; 1 1 : - p u i c
}
v o l d LaterQ; 1 1
};
void Vag ue( l n nerSelf& i , int n )
{
ia n ; 1 1 : la?
i . la = n; 11 : la - prl vate
i . i b n ; 1 1 : l b - p u i c
}
};
=

l n nerSelf shal low; 1 1 :


O ute'rS hel l : : l n nerSelf deep; 11
1 1 - acca . l n nerSelf
void O uterS hel l : : l n nerSelf: : LaterQ { / * . . . * 1 }


typedef (. "" "
" "") .

++

63

.

, .
-
(iline) . (. "-")

(. "-") .

vold ContrlvedQ
{
l nt 1 ;
static s ;
classloca l
{
11
p u I Ic:
i nt fQ { retu rn i ; } 1 1 : 1 -
11
i nt gQ { return s ; } 1 1 : s -
11
};
11
. . .

. . .

}
Local vacuous; 1 1 : Local
11

- . . .

,
, .
( private) ,

64

++
( protected) I ( public) .

home.a rea = 708;


11 : prlvate
home. handset = offH ook; 1 1 : protected
lf{ home. OffH ookQ )
1 1
home.GiveDiaiToneQ;

(static) . ,
,
.
(
m ) ,
.
r I
. .. ;
,

1 1 S ha pe. h
class S ha pe
{
static l nt n u m S ha pes ; 1 1
11 . . .
;
}
1 1 Shape.c
i nt S ha pe: : n u m Shapes = ; 1 1

! const. :

, , - .

++
.

++

65

(. " :" ) .
,
,
.

class Phone
{
con st l nt a rea , exchange, l l ne;
11 ...
p u ic:
Phone( l nt , l nt , l nt 1 ) :
a rea( ), exchange( ), l l ne( 1 )
{
11 ...
}
11 ...
};

: .
,
(. "
" ) . ,
.

class Phone
{
11 ...
p u ic:
Phone( l nt, l nt, l nt ); 1 1 .
11 ...
};

.
{ }.
3

3-207

66

++

class Car
{
11 . . .
Phone phone ;
p u / ic:
Ca r( / * . . . * / , i n t , i nt , i nt 1 ):
phone( , , 1 ) { / * * / }
11 . . .
};
. . .

- . . .

, -
.

,
.

. - ,

, inline .

.
-,
.

-
. -
.. ,
,

inline.

-
. .


iniine.
q !'J).

++

67

1 1 l ntStack . h
class l ntStack
{
i nt * v , size , top :
p u i ic:
11 ...
l nt con st; 1 1
vold P u s h( l nt ); 1 1
:
}
i n l i ne i nt l ntStack: :TopO const { retu rn v[top]; }
1 1 1 ntStack.c
void l ntStack: : P u s h( i nt element )
{
lf( top+ 1 < s ize ) v[++top] = element:
}

this ,
,
.

. , ,
.

class Node
{
11 ...
Node * n ext;
p u i ic:
11 . . .
vold l n sertAfter( Node * )
{
if( t h i s && ) 1 1
l

68

++

next = p->next: 1 1 n ext - thi s->next


p->next = th l s : 1 1 thi s
}
}
};
r,
- r .

, : .

class PhOne
{
11 ...
p u i ic:
P hone& G iveDia iToneQ:
11 . . .
}:
P ho n e & Phone: : G i veDiaiToneO
{
11 ...
retu rn *th l s : 1 1 *th i s - P hone&
}
P hone home( 5 1 6, 555, 8858 ):
long d i g its = home.G i veDia iToneQ.AcceptDig itsO:
11 . . .
1 1 home.G i veDiaiToneQ: . . .
1 1 long d ig its = home.AcceptDig itsO :

static. -

this ( . " ") (. "


" " " ) .

++

69

f
. - **
const virtual .

( ) ,
fti. .

class S ha pe
{
static i nt n u m S ha pes;
protected :
Point center;
p u i ic:
S ha pe( Point ) : center( ) { ++n u m S ha pes ; }
..., S hapeO { -numSha pes ; }
11 ...
static i nt N u m S ha pesO { return n u m S ha pes; }
};
11 ...
for( i nt n = Shape: : N u m S ha pesO: n > ; -n )
11 ...
static
.

class S ha pe
{
static l nt n u m S ha pes; 1 1
};
*

++ }f -.
** , -
this,
.

70

++

11 ...
i n l i n e i nt S h a pe: : N u m S hapesO 11 static
{
retu rn n u m S hapes:
}

const,

.
.

- (
).

class l ntStack
{
i nt * v , s ize, top:
p u ic:
11 . . .
i nt PopQ:
i nt const; 11 -
:
}
voi d f( const l ntStack & s ) 1 1
{
i nt = s.TopO 1 1 : - n
i nt = s . PopQ; 1 1 : s
11
}

volatile. volatile
volatile -. -

-++ -.

++

71

- const vo1atile.

(. "
" " ").
-
.

. . .

) r < - ).

struct Polnt 1 1 . " -


1 1 - "
{
l nt , :
vold Set( l nt , l nt ) { = , = : }
}:
Pol nta , * = & :
1 1 plnt - i nt Poi nt
i nt Point::*pint = &Pol nt: :x: 11
1 1 pmf2i - -
11 Point,
11 int void

void ( S::* pmf2i ) ( int , int )

&S: :Set;

++ ( . * pint ) ; 11
++ ( pa->* pint ) ; 11
( a . * pmf2i ) ( 1 , 1 ) ; 11 Set O
*

int - 1 int,
fu, . ++
.

72

++

( pa->*pmf2i ) ( 2, 2 ) ; 1 1 Set


, (. " "
" ") .
void,
.


. , ,
.

r ,
,
,
new.
,
, (. "
" " "
" " ) .
, ,
.
, ,
.

,
JS
.
,
-
.

++

73


( -) .

class 1 ntStack
{
l nt * v, s lze, top;
p u ic:
l ntStack( l nt ezl s ) ; 1 1
11 ...
};
l ntStack: : l ntStack( l nt ezi s )
{
v = n ew l nt[ s lze ezi s ];
top = - 1 :
}
=

1 1 l ntStack.
l ntStackh uge( 1 000 );

const, volatile, static,


virtual. .

( ) .

l ntStack good( 1 00 ):
l ntStack bad = l ntStack( 1 00 ) ; 1 1
l ntStack ugly = 1 00; 1 1


, ( 'I
,
) .

74

++


-----------------



,
( . "
" "") .
,
,
(. " " ) .

class Stri ng { /* . . . * 1 Stri ng( con st char * ): } :


class B itStri ng { /* . . . * 1 B itStri ng( Stri ng ): } :
void f( con st Stri ng & s" ) { /* . . . * 1 }
void g( con st B itStri ng & ) { / * . . . * 1 }
11 ...
f( " H el lo" ) : / / Stri ng( " Hello" )
g( " 1 0 1 1 0" ) : / / :
1 1 B itStri ng( Stri ng( " H ello" )")

, .

. ,
,
( . " -") .

.
,
.


.
{ }.

++

7S

class 1 ntStack
{
con st l nt s lze;
11 ...
;
}
l ntStack: : l ntStack( l nt ezl s ) : slze( ezl s )
{
v = new l n't[ s lze ];
top = - 1 ;
}

, , -

( ,

) .

,

nw.

1 1 -
1 1 l ntStack
l ntStack * new l ntStack[ 5 ]; 11
=

class l ntStack 1 1 l ntStack


{
11 ...
l ntStack{ l nt 20 ) ; 1 1
11 ...
};
=

,
,
- , .

76

++

1 1 20
l ntStack * new l ntStack[ 5 ]; / /
=

.r.t ICocmpyiCmopa
,


( ,

) .
.u In,

6
6

,
, 5!

.

class 1 ntStack
{
11 ...
p u i ic :
l ntStack( i nt 1 0 ) ;
l ntStack( con st l ntStack& ) ;
11 ...
=

( & ) ( const & ) ,


.
,
, .

, ( ) .

,
, v
.
,
(. " " "
" ) .
,
.

++

77

};
l ntStack: : l ntStack( con st l ntStack& from )
{
v new l nt[ s lze = from . size ];
for( reg l ster l nt 1 = ; 1 < s ize; ++1 )
v[l] = fro m . v[l];
top = fro m .top;
}
11 . . .
1 ntStack ( 1 0 0 );
l ntStack ( ); 1 1 ,
l ntStack = ; 1 1
=


, .
,
.

,

.
r- ,

.

P hone office(]
1 1
{
708, 555, 8887'
708, 555, 7255
};
P hone offlce[ ] =
1 1
{
=

++ .
,
.
**

78

++

708, 555, 60 1 2 , 1 1 ,
708, 555, 3707 1 1 P hone
};

. . .


.
:
- ;
-
;
-
;
- delete ,
.

, ,
"" (-). :)>..fr
,
.
( . "
-" " ").

c l a s s l ntStack
{
i nt * v , s ize, top ;
pu i c :
l ntStack( i nt esiz 20 );
"' l ntStackO { delete[ ] v }; 11
=

};

11 ...

++

79

11 ...
l nt m a i nQ
{
l ntStacks{ 1 00 );
l ntStack * ps new l ntStack{ 50 );
11 . . .
delete ps; / / ps
11 s
}
=


( ) .

l ntStack s( 1 00 ) , * ps = new l ntStack( 50 );


//...
s . .... l ntStackQ; / / s
thi s->,.., l ntStackQ; / / *th l s

. . .

class
class.
. . .
operator type() { / * . . . * / }
. . . ,

, :
.
<

,
.
.

11 .

80

++

(JJi
, ,
(. "
" "" ) .

class Stri n g
{
char * s ;
p u ic:
11 ...
operator con st char * con st { retu rn s ; }
};
voi d f( const char * s ) { /* . . . * 1 }
Stri ng s ;
11 ...
f( s ) : 1 1 : s .operator con st char *

,
(. " :" ) .

class B itSt.ri ng { /* . . . * 1 operator Stri ngO; } :


B itStri n g ;
1 1 ...
f( ); 1 1 :
1 1 b .operator Stri ngO.operator con st char *
"

: (. "
-:" ":
:") .

++

81

-
- . . .

,
r, struct

JI union.

,
public, .
.
, pnvate .

1 1

class Tu re : p u i c
{
i nt ;
protected:
int f();
p u I Ic:
TrueQ;
i nt gQ;
};
class l m ltator :
{
l m ltatorQ:
l nt gQ;
protected :
i nt f();
private:
i nt ;
}:

r. <; ,
-.

82

++

-
, ,
.
-
,
-,
. -
, -,
.

. . .

,
, ,
, .
.

,
*
.
.

class Person
{
i nt secret; 1 1
p u ic:
11 ...
fri e n d voi d S pou se( Person & ) ; 1 1
};
11 ...
void S pou se( Person & )
{
*

, , .

++

};

83

++p. secret; 1 1
I .

c l a s s Person
{
11 ...
fri e n d v o i d Fam i ly: : S i i ngQ;
11 Fa m i ly: : S i b l i ngQ -
};

r .

c l a s s Person
{
11 . ..
fri e n d class Fa m i ly ;
1 1 - Fa m i ly
11
};

,
.

c'l a s s Fa m i ly
{
fri e n d class D i sta ntRelative;
11 ...
};
c l a s s D i sta ntRelative : p u b l i c Fa m i ly
{
voi d P ry( Person & )

84

};

++

++p. secret; 1 1
1 1 D l stantRelatlve
1 1 Person ,
1 1

(
" ") .

class D l sta ntRelatlve : pu ic Fam l ly


{
vold P ry( Person & )
{
++p. secret; 1 1
1 1 D i stantRelatlve
1 1 Person ,
1 1
}
};

++

IJ

85

. . .
,
, .

.

. . .

.
private, protected
pulic .
private.
Private -
i.
Protected
*
.
-

Public -

.

Base
Private

private
protected
pulic
1

**

Derived

private
protected
public

, -++

USL .O.
**

,
,
.

86

++
Protected

private - - - - -private
protec
protected
pulic
pulic

Puiic

private - - - - - private
protected
protected
pulic
public

,
,
.

class P hone
{
1 1 . Phone " "
/ /. . .
};

1 1 Phone p u i ic
1 1 PayPhone
class Pay P hone : p u / Ic Phone
{
l nt cents Deposlted ;
p u I Ic :
PayPhone( l nt a rea , i nl: exchange, l nt l i ne );
vold G i veDia iToneO;
l nt AcceptCo i n sO;
;
}
1 1 -
PayPhone booth( 708, 555, 5444 );

- . . .

++

87

,
-


.

class Pay P hone : p u I Ic Phone


{
11 ...
p u i ic:
11 . . .
void G i veDiaiToneQ; 1 1
};
P hone home( 5 1 6, 555, 8858 );
PayPhone booth( 708, 555, 5444 );
11 . . .
home.G iveD i aiToneQ; 1 1 Phone::GiveDiaiToneQ;
booth .G i ve D i aiToneQ; 1 1 PayPhone : : G i veDiaiToneQ;

- ,
.

vold PayPhone::G iveDia iToneQ


{
1 1 - Pay P hone . . .
*
P hone: : G i veDiaiToneQ; 1 1
}

, .

88

++

. . .



.
'
.

,
,
.

class Base
{
l nt ;
vold gQ;
p u ic:
l nt , ;
v old fQ. f( l nt ). g( i nt );
};
class Derlved : private Base
{ 11
p u ic:
Base: :a; / 1 : '' p u i c
Base: : b ; / 1 puic
l nt c;
Base::c; / 1 :
Base::f; / 1 fQ puic
Base: :g ; / 1 : gQ
11
};
. . .

, ,
, .

++

89

:
: (. "
- ") .



, . , .
.
. -. ..
J .
, ,
I 1: ,
:.
.

class P hone
{
11 ..
puIIc:
v l rtual void G lveDi aiToneO; 1 1
11 . . .
};
.

class Pay P hone : p u i c P hone 1 1


{
i nt cents De-pos ited ;
p u ic:
PayPhone( i nt a rea, i nt exchange, i nt l i ne );
void G i veDiaiToneO;

90

};

++

l nt AcceptCoi n sO:

11 ...
P hone home{ 5 1 6, 555, 8858 );
payP hone booth( 708, 555, 5444 );
P hone * ; 1 1 P hone
= &hom e; 11 . . .
p->G iveDiaiToneO : 1 1 Phone::GiveDiaiToneO
= &booth ; 11 . .
p->G iveDiaiToneO: 1 1 PayPhone::G iveDiaiTon eO


IJ. ,
nJ
-.
- - -,
,r<l>,
.
- .

struct Point
{
l nt , ;
Poi nt( int =, = ) { = , = }
};

r . ++ .
.
,
r .

++

91

c l a s s S h a pe 1 1
{
p rotected :
Point center;
p u ic :
S ha pe( Point ) : center( ) { }
v i rtu a l Shape& D rawO const = ; 1 1
1 1
};
c l a s s C l rcle : p u ic Shape
{
i nt rad i u s ;
p u ic:
C l rcle( Point , i nt r = 1 );
S ha pe & D rawQ con st; 11 D rawO
};
11 ...
S h a pe amorp h u s ; 1 1 :
C l rcle ;
Sha pe * = &; 11 :
11 Shape

: .


- .
,
, ,
, , ,
.

class Phone
{
11 ...

92

++

p u ic:
Phone( i nt , int , i nt 1 )
{
11 ...
AcceptDig itsQ; 1 1 . . .
}
v i rtual void G iveDiaiToneQ; 1 1 . . . . . .
long AcceptDig itsO
{
11 ...
G iveDiaiToneQ; 1 1 . . .
1 1 , . . .
}
11 ...
};
class PayPhone : puic P hone
{
11 ...
pu ic:
11 ...
void G i veDiaiToneQ; 1 1 .
11
};
.

. . .

.

,

, ,
, .
.

93

++

:,
,
.
(. " ") .

class P hone
{
11 ...
p u I Ic:
P hone( l nt, l nt, l nt ); 1 1
11 . . .
};
class PayPhone : p u I I c P hone
{
11 ...
puIIc:
PayPhone( l nt , l nt , l nt 1 ) : P hone( , , 1 )
{
11 ...
}
11 ...
;
}

-

-.

, , -
(. " -") .
-

++ .
(. " " " ") .

94

++

- (. "
- " ) .

. . .

.
.
.
-
-.

, ,
- . -

. . .
*

.
\>; .
. ,

,
,
, ,
.

class { p u ic: void fO; /* . . . * 1 } ;


class { p u i ic: void fQ; /* . . . * 1 } ;
class : p u i c , p u ic { /* . . . * 1 } ;
11 ...
;
c.fQ; 1 1 : fQ, ?
*

++ .

**

, .
.

++

95

c.A : : fO; 1 1

.

class : p u i ic , p u ic
{
11 ...
p u ic :
void f0 { A : : fO; B : :fO; } 1 1
1 /. . .
};
11 ...
;
c .fO: 1 1

, i
,
.

struct { i n t 1 : /* . . . * 1 ( l nt ) : } ;

class : p u I I c { /* . . . * / ( i nt ); } ;
class : p u b l l c { /* . . . * 1 ( i nt ) : } :
class : p u b l ic , p u b l ic { /* . . . * 1 ( i nt ); } ;

:

96

++

r r
r ,
.

( ):
++c. l ; 1 1 : 1 , ?
++c.A: : I ; 1 1
* n ew ( ) ;
* : 1 1 : ?
* = ( * ); 1 1
=

. . .

, r
.. ,
r r .
r
virtual
. r r .

struct V { l nt 1 ; / * . . . * 1 V( i nt ) : } ;

class : v l rtual p u i c V { /* . . . * 1 ( l nt ) ; } :
class : v l rtual p u ic V { / * . . . * 1 ( l nt ); } ;
class : p u ic , p u b l l c { / * . . . * 1 ( l nt ) ; } ;
.
r r
r ,
r .

, virtual -
.

++

97


- , -
,
.

struct V { i nt i ; void fO; /* . . . * 1 } ;


struct : v i rtual V { int i ; i nt fQ ; /* . . . * 1 };
struct : v i rtual V { /* . . . * 1 } ;

class : p u i c , p u i c
{
11 ...
void gQ { i = fO: } 1 1
1 1 A: : i , A : : fQ V: : i V::fQ
}:
it, ,

l'!{ .

V : : V( i nt n ) : i( n ) { /* . . . * 1 }
: :( i nt i ) : V( 1 ) { /* . . . * 1 }
: : ( l n t i ) : V( 1 ) { /* . . . * / }
: : ( l nt 1 ) : V( i ) ( i ), ( i ) { /* . . . * / }
,

4 3-207

98

++


- .

class V
{
11 ...
p u I Ic:
vold t0 { /* . . . * 1 }
11 ...
};
class : v i rtu a l pu i ic V
{
11 ...
p u I Ic:
vold tO { /* . . . * 1 V : : fQ; }
11 ...
};
class : v l rtual p u i i c V
{
11 . .
p u b l ic:
vold fQ { /* . . . * 1 V::fQ; }
11 ...
};
.

class : p u b l ic , p u b l i c
{
11 .
p u b l lc:
void fQ { /* ... * 1 A: :fO : B : :fQ : }
1 1 , V: :fQ
}:
.

++

99

real_f O , ,
fO .
f O
real_f O , - f O .

class V
{
11 ..
protecte d :
voi d rea l_fQ { /* . . . * 1 }
11 ...
puiic:
void ro { rea l_fQ; }
11 ...
};
.

c l a s s : v i n:u a l p u i c V
{
11 ..
protected :
void rea l_fQ { / * . . * 1 }
11 ...
p u ic :
void fQ { rea l fQ; V: : fQ; }
11
};
.

. . .

c l a s s : v i n:u a l p u i c V
{

11

. . .

p rotected :
void rea l_fQ { / * . * 1 }
. .

11 ...
p u I Ic:

vo i d fQ { rea l_fQ; V : : fQ; }

11 ...

100

++

}:
class : p u i c , p u i i c
{
11 . .
p rotected :
vold rea l fO { / * . . . * 1 }
11 ...
p u ic:
vold fQ { real_fO: A: : rea l_fQ; B : : rea l_fO: V : : rea l_fO: }
11 ...
}:
.

li

. . .
,
. ,

" " .

. . .

,
.
template, ,
< >.
,
class, .
.
.

, .

, ++ USL 3.0 (UJ.. .


Borland ++ n , 3.0) .

class ,

++

101

1 1 :
tem plate <class > con st & ( con st & , con st & );
11 . . .
*
tem plate <class > con st & 1 1
( con st & , con st & )
{.
retu rn > ? : :
}
11 ...
int i, j;
float , ;
11 ...
l n t k = ( 1 , j ) ; 1 1 ( l nt , lnt )
float = ( , ) ; 1 1 ( float , float )

-
.

tem pl ate<class > con st & ( const &, con st & );


tem pl ate<class > con st & ( con st *, l n t );
i nt ( i nt ( * ) ( i nt ), i nt ( * ) ( i nt ) ) ;


, ( ) -
, -
( ) .

const char * & ( con st char * & , con st char * & d )


{
1 1 . . . -, char * . . .
}

-
- , r
. .

102

-++
. . .

template.


, .
(
) .

1 1 Stack,
11
tem p l ate<class > class Stack
{
* v; 1 1
l n t s lze, top ;
p u ic:
Stack( l n t ezi s );
"" StackQ;
vol d P u s h( const & ) ; 11
& PopQ; 1 1
& const; 1 1 ..
};
Stack <int> i; 1 1 int
Stack<char*> ; 1 1 char*

(
:) . ,
, .

1 1
tem plate<class . int s ize> class Stack

++

103

v[ s ize ]; / / *
i nt top;
p u i ic :
StackO : top( - 1 ) { }
11 ...
};
Stack< i nt, 20> tiny;
Stack< i nt, 500> huge ;
tiny huge

int,

,
. ,
Stack<int,
Stack<int,

20> - ,
500>.

Stack< i nt, 20> * is20p &ti ny ; 1 1


Stack< i nt, 500> * i s500p &ti ny; 1 1
=

- . Q
, -

**

c l a s s { /* . . . * 1 }:
tem p l ate< c l a s s > c l a s s : p u i ic { /* . . . * 1 }:
tem pl ate< c l a s s > class : p u i i c { / * . . . * 1 } :
c l a s s D : p u i ic C< i nt> { /* . . . * 1 } :


, v
new ( ) .
**

- r w , - " "
. int.

1 04

++

, ( ) -
, (

) .

1 1 char*
class Stack<char*>
{
char * * v ; 1 1 char*
i nt s i ze , top;
p u I Ic:
Stack( i nt ezi s ) ;
'"" S tackQ :
vold P u s h ( con st char* & ) :
char* & PopQ :
char* & const:
};

-
(. " - -
"

" " ) .

- . . .


-.

(
) ,
template.

tem p l ate<class > class


{
static i nt i ; 1 1
static t; 11
11 ...

++

105

};
template<class > int C<T>::i; 11
template<class > C<T>::t; 11
1 1 ...
C<char> ; 1 1 int C::i char C::t
C<float> f; 1 1 int C::i float C::t

- . . .

,
, template.

tem plate<class > vold


Stack<T>: : P us h( con st & element )
{
if( top
s lze 1 )
error( " stack overflow" );
else v[++top] element;
}
=


r, ( ) -
, -
( ) .

vold Stack<char*> : : P u s h( con st char* & ccpr )


{
1 1 char*
}

. . .

r
. .
3-207

106

++

.
template.
U , - U
.

tem plate <class > class Person


{
friend void PetO;
frien d void S pou se( Person & );
tem plate<class U > friend void Coworker( U& );
};

11 . . .
void PetO { / * . . . * 1 } 1 1

tem plate<class > void Spo use( Person & ) { /* . . . * / }


tem p late<class U > void Coworker( U & u ) { / * . . . * 1 }
Pet () - , Person<T>
:r .
Person<int>

Person<float>
r , int, Spouse ( Person<int>& ) , P e r s on < i n t > ,
Person<char>, r .
Spouse ( Person<int>& )

-----

Person<int>

1 07

++
Spouse ( Person<char>& )

-----

Person<char>

Spouse ( Person<float>& )----- Person<float>


Coworker( U& ) - , Person<T>,
U .

Coworker( int& )

Person<int>

Cowoker( char& )

Person<char>

Cowoker( float& )

Person<float>

- .

tem plate<class > class Person


{
11 ...
frlend void Fam i ly: : S i b l l d i ngQ;
friend voi d Acq uai ntance: : Casual( Person & );
tem plate<class U > friend voi d
N e i g h bor< U > : : NextDoor( U & );
};
Family: :Sibllding () - ,
Person<T>, .
, int,
Ac quaintance<int>: : Casual ( Person<int>& ) - ,
Person<int>, Person<char>,
.
Neighor<U>::NextDoor( U& ) - ,
Person<T>, U.

1 08

++

tem plate<class > class Person


{
11 ...
friend class Fa m l ly;
frlend class Acq ual nta nce;
tem plate<class U > frlend class Nelg h bor:
};
-
Family - , Person<T>.
, int, -

A c q a i n t a n c e < i n t >
Person<int>, Person<char>,
.
U -
N eighor<U> Person<T>.

I .

. . .


, : : , sizeof, ? : , ., ..
,
operator,

I .
u

, Ji
.
.
.

++


. , i int, ++i - ,
i+= 1, , i=i+ 1.
,
.
.

109

-
, . @
x.operator@ O r @.
,
r- ,
. r
@
.
*

operator@
(x)

r
@.

class
{
operator-Q con st; 1 1
operator&O con st; 1 1
operatorO con st; 1 1 :
};
class
{
friend operator-( con st & ) ; 1 1
fri e n d operator&( con st'(& k 1 1
fri e n d operator( con st & ) ; 11 :
1 1
*

,
.

110

++

};

I ,
. @
x.operator@ (y) r @.
: : ,
r- , .

, .
@, =, @
operator@ ( , ) .

class
{
operator-( con st & ) con st; 1 1
operator&( con st & ) con st; 1 1
operatorl( con st & ) con st; 1 1 : 1
11 n
};

class
{
frlend operator-( const &, const & );
frlend operator&( const &, con st & );
'frl e n d .V' operatorl( con st &, con st & ); 11
};

"


.
.

++

111

-.

class
{
11 ...
puic:
( l nt , l n t , l nt );
11 ...
vold operator ( l nt i , l nt j , l nt k );
};
Xa mple( 1 , 2 , 3 ); 1 1
Xam ple( 4, 5, 6 ); 1 1

. . .
)' r
r r.

,
r r
r.
, ,
: J
.
, : .
.

,
,
,
.
( . "'I' " "") .
,
.

1 12

++

class l ntStack
{
l n t * v, s ize, top;
p u ic:
11 . . .
l ntStack& operator=( const l ntStack& ) ;
};
l ntStack& l ntStack::operator=( const l ntStack& from )
{
lf( thls 1 &from ) 1 1 from from
{
delete[ ] v ;
v n ew l nt[ slze = from.slze ] ;
for( reg l ster lnt 1 ; 1 < s ize; ++1 )
v[l] = from.v[l];
top = from .top;
}
retu rn *thls; 11
1 1
}
11 ...
l ntStack ( 1 00 ) , , ;
11 ...
= = ; 1 1
1 1
=

. . .

++

1 13

,
.

class Strl ng
{
char * s;
11 . . .
puiic:
Strl ng( char );
Strl ng( con st char * );
char& operator{ l nt pos ) { retu rn s[ pos ]; }
11 ...
};
Strl n g bal l " m itten" ;
_b a i i[O] 'k'; 1 1 char&
... ...
=

x->m (x.operator-> 0 ) ->m .


, ,
, . .
-

,
, ,
,
-> ,
.

.

String pos,
operator [) , .

++ .
-> * ,
.

1 14

++


. . .

,
. .
: - ,
,
, ,
.
: - ,
int,
, t
int
.

class
{
1/
p u ic:
& operator++(); 11
& operator++{ i nt ) ; 11
};
. . .

class
{
1/
p u ic:
friend & operator-( & ) ; 11
friend & operator-( &, i nt ) ; 11
};
. . .

Ci+ .

int .
.

++

1 15

new d e l ete . . .


.
void *
new void delete.
size_t,
<stddef.h>.
- ,
, ,
.

#include <stddef. h>

class Thing
{
/1 . . .
e n u m { k = 20 } :
static Thing * freelist;
p u ic :
11 ...
void * operator new( s ize_t ):
void operator delete{ void *, s ize_t ):
}:
void *Th i ng::operator new( s ize-t size )
{ .
Thi n g * ;
if( lfreeli st )
{
freelist = = ( Thi n g * )new charfsize*ock];

++ new delete.

l l

++

whl le( != &freeList[ lock-1 ] )


p->next = + 1 , ++;
p->next = ;
}
p=freell st, freellst = freell st->next;
return ;
}

vol d Thl n g : :operator delete( void * , s lze_t )


{
( (hlng *) }->next = freelist;
freellst = (hlng *);
}

,

r .
new ,
.
, ,
new.

class Thl n g
{
11
p u ic:
11
/*
** buf,
**
* * Thl n g
*/
vold * operator new( s lze_t s lze, vold * b u f );
};
1/...
. . .

. . .

++

1 17

vold * Th l n g : : n ew( s lze_t s lze, vold * buf )


{
1 1 Th l n g buf
}
11 ...
char buffer[ 1 000];
Thl n g * n ew( buffer ) Th lng ;
=

new
t-::rtr new.
new
.

Th l n g * n ew Thlng ; 1 1 :
=


new,
new, - size_t size.
I ::operator new.

class Thl n g
{
11 ...
vold * operator new( s lze t s lze, vold * b u f );
vold * operator new( s lze=t slze )
{
ret u rn : :operator new( s ize );
}
};


++. ,
, ,
.
++ ANSI .
m ++, ,
ANSI " ".

.
, #
, .
, ,
. ( \ )
.

. . .

, I
,
++.

#defi n e S IZE256 1 1 -
11 ...
for( i nt i = ; i < S IZ E ; ++i )
11 ...
1 1 ++
for( i n t 1 = ; 1 < 256 1 1 -; ++i )
1 1
1 1

1 19

, 1 1 , ,
, J
J.
J,
J,
, 1 ... 1 .

#defl ne S IZE 256 /* - * 1


for( l nt 1 = : 1 < 256: ++1 )
1 1

. . .

J
.

_cpl u s p l u s

++.

LI N

J .

F I LE

4.

DATE

: Mmm dd .

TI M E

: hh:mm:ss.

. . .

#.

# l i ne " _ "

J, ,
._ -

1 20

++

.

(_LINE_) , .._.
LFILE_) .
.
-

# i nc l ude < _ >


# i ncl ude " _ "

.

:r
I ++ .
:r
.

#lnclude <lostrea m . h> / /


1 1
#lnclude " M e H eader. h " //
11

#pra g m a

.
.

r ( , ++) .

, , .

.

121

#define
#define
( ,

.
, f ,

#defl ne forever for( ; ; )


11 ...
forever { / * * 1 }



n
"
. . .

.

#defl ne M I N(a , b) ( () () ? () : () )


, .
r #.

#defl ne MAI iog ld) " / u s r/ma i l / " #log lt


11 ...
l f stream m a i i FI Ie( I pj l ) ):
11 I pj l ) " / u s r/ mal l / " " pj l " ,
1 1 " / u s r/ ma l l / pj l "

const .

inline.

1 22

++

#undef

. i,
.

# u ndef M I N

#error

.si, r .

. . .

,
( )
.
:
#if -

/ * ? * /

#ifdef

/ * ? * /

#ifdef

/ * ? 1

#if - ,
- () ,

#else, #elif #edif.
#ifdef ( #ifndef)
, ( )
.
..-.
defined ,
.

1 23

! defined .

"" ,
:
#else
#elif
#else
, I
, .! #if.
#elif m #else ,
, ..
...

#endif.

#ifdef D E BUG
cerr << "cou nter
#en d if

"

cou n ter en d l ;

#if defi ned SYSV


extern long fQ;
#el if defi ned B S D
extern short fQ;
#else
extern i nt fQ;
#en d if


(" .h") .

defined,
#ifdef ;Jifndef. Ji
( , #ifdef #if defined) .

1 24

++

1 1 P hone.h

#lfndef P H O N E
#defl ne =P H O N E_
class P hone { /* . . . * 1 } ;
#en d l f

1 1 PayPhone. h
# ifndef
#defl ne

PAY P H O N E
PAY P H O N E-

# l n c l ude " P hone. h "


class PayPhone : p u i c Phone { /* . . . * 1 } ;
#en d l f

1 1 my.c
# l nclude " P hone. h "
#l nclude " PayP hone. h "
1 / ...
m y. : Phone,
Phone.h, :- Phone, :
PayPhone.h.
#include my . :
Phone.h.
_PHONE_ : Phone.
: #include : my .

1 25

PayPhone.h.
_YPHONE_. hn
Phone, PayPhone.h
P h on e . h .
..:_PHON E_ , 6
Phone .
,
6 Phone.


/
++ / .
/ I .
, ,


/ :

ios
i stream
ostream
iostrea m
ifstream
ofstream
fstream


:
ios

.
ostream

tstream

stream
"fstream

fstream
1
fstream

stdio . ++ .

1 27

1 . . .

.
: eofit, failblt badblt.

.

i nt eof()

,
.

i nt bad ( )

,
.
.

i nt fa i l ( )

,
,
, .
,
,
. r,
,
bad ( ) .

i nt good ( )

, f() , bat () fail ()


.

1 28

++

i nt rdstate()

vo i d c l ea r( i nt state )

i strea m s ;
1 1 fa i l b lt,
s.clear( los: :fa i i t 1 s. stateO ) ;

i nt operator ! ( )
operator vo id()

,
failblt badblt.
, failblt badblt.

if( lmyStream ) 1 1 operatoriO


if( myStrea m ) 11 operator void*Q

. . .

ostream iostream.


,
.
:
cout

ostream,

1 29

cerr

ostream,

. . .

<<.

..,

char void.

cout "Wowl Thi s i s neat! / n " :


cerr " Ba d opera n d : " ' / n ' :

class Phone
{
i nt a rea, exchange, l i ne:
11 . . .
fri e n d ostream & operator(ostream & , const Phone& ) :
}:

ostream & operator( ostrea m & os, con st Phone& )


{
os ( p.area ") " p.exchange p. l i ne ;
retu rn os : 1 1 ostrea m &
'

'

'-'

.
.

,
, .

130

++

}
11 ...
cout " n u m ber: " home ' / n ' ;

ostrea m & put( cha r )

cout. put( ' / n ' ) ; 1 1 , cout ' / n ' ;


cout.put( 1 ).put( bel l );
'

'

ostrea m & write(


const c h a r buf, i nt count )
ostrea m & write(
const u nsig ned cha r"' buf, i nt cou nt )


, buf.

const l nt bufSize = 2048;


char buf[ b u fS ize ];
11 . . .
cout.wrlte{ buf, s lzeof b uf );

ostrea m& f l ush()


ostrea m& fl ush ( ostrea m & )

.
- , - .

>>
.

131

cout "What's you r name? / n "


cout.fl u s hQ;
11 ...
cout "Where do you l i ve? / n " fl u s h ;

ostrea m & seekp(


strea m pos, seek_d i r = i os : : beg )

.
, seek_dir
,
: ,
.
streampos

fl leA. seekp( 1* 1 00 ) ; 1 1 1 1 00
fl l e B . seekp( 1 00, los : :c u r ) ; 1 1 1 00
fi leC. seekp( , los : :end ) ; 11

strea m pos tel l p()


. streampos - t .

stream pos mark

myFI Ie.te l l pQ;

ostrea m & end l ( ostrea m & )

' \ n' flush.

cout " H ello, worl d l " e n d l ;

132

11

++

. . .
q
istream iostream.

cin , i
.

. . .

qr
. ; .
>>.

char.

l nt age, wei g ht;


cout " E nter age a n d wel g ht: " fl u s h;
c l n age >> welg ht; 11 .
11

,
(
operator void* ) .

char ;
whl le{ c l n ) 1 / c l n
1 1 cout
cout ;

JI get() ,
getllne () read ( ) .

133

failblt, ,
, . badblt,
.

,
(. " 1'
" I") .

i nt get()

, ( .
: , ..) .

EOF,
( failblt) .

,t ;
whl l e( ( = c l n .get() ) != E O F )
cout. put( );

i strea m & get( char& )


istrea m& get( u n s i g ned char& )


, .
,
.

EOF .
- 1 .
char,
char unsigned char, int.
ero

1 34

++

char c;
while ( ci.get ( ) ) , cout.put ( ) ;

istrea m & get( c h a r buf,


i nt l i m it, char d e l i m = '\n ' )
i strea m & get( u n s i g ned char buf,
i nt l i m it, char del i m = '\n' )

,

-.

.

i strea m & getl i ne( char buf, i nt l i m i t,


char d e l i m = '\n' )

,
,
-.
.

i strea m & read ( char b uf, i nt count )


istrea m & read ( u n s i g n ed char buf,
i nt cou nt )

con st i nt bufSize 2048;


char buf[ bufS ize ];
11 . . .
=

135

cout.read( b uf, bufS ize );

r,

, failit .

i strea m & i g nore( i nt l i m i t= 1 ,


i nt deli m=EOF )

,
-r. .

i nt gcount()

,

r .

i strea m & putback( char )

. ,
get ()
. , ,
, ,
.

i nt peek()

, tf
, ero .

istrea m& seekg( strea m pos,


seek_d i r=i os : : beg )

streampos - r , seek_dir

136

++

: ,
.

fl leA.seekg( 1* 1 00 ); 1 1 1 1 00
fl leB .seekg( 1 00, los : :cur ); 1 1 1 00
fl leC. seekg( , los::end ); 11

strea m pos tel lg()


. streampos - .

stream pos mark

myFIIe .tel lgQ;

istrea m & ws ( istrea m& )

c l n ws; 1 1
11 ...

1 . . .


ofstream fstream.
fstream.h.
:,
, ofstream :
ostream .
.

137

ofstream outFI Ie( " myFIIe" ) ; 1 1


1 1 myFi le
if( loutFIIe ) 1 1
{
cerr "can not open / " myFIIe/" for output/n " ;
exlt( 1 ) :
}
outFIIe "Wowl Thl s l s even neater! / n " ;
,
I,
(. "" "
/ ") .

ofstrea m afterthoug ht( " my F i l e " , los : : a p p ):


afterthought "On the other ha n d . . . / n " ;

1 . . .
m
ifstream fstream.
fstream.h.

,
, ifstream
ostream.

ofstrea m i n Fi le( " myFile" ) : 1 1


// myFIIe
i f( l l n F i l e ) 11
{
cerr "ca n n ot open / " my F i l e / " for output/ n " :

3-20'1

138

++

exlt( 1 );
}
lnt , ;
l n F I Ie ;

11

/
vo i d open( c h a r na me,
i nt mode = i os : : out,
i nt prot fi lebuf: : open prot )
=


*
. mode :

los : :app


(
ios::out) ;

los : : ate


(
ios: :out) ;

los : : l n

los: :out

ios: :tru nc


( ios::out) ;

l os : : n ocreate

,
;

i os : : noreplace

,
.

139

prot .

vo i d c l ose( )

ero .

lfstream encyclopaed ia;


11 ...
for( l n t 1 = ; 1 < n u mVo l u mes; ++1 )
{
encyclopaed l a.open( vol u me[ 1 ] );
lf( lencyclopaed l a )
1 1
1 1
encyclopaed ia.closeO;
}

1 .

. . .



.
r,
flags () ,
setf() unsetf .
m
setf() . m.

skl pws
*

,
'

140

++
.

left,
rig ht,
i nterna l


(. fill )
.

ios::adjustfield.

dec, oct, hex

,

.

, - :
, ++
. :
ios::basefield.

s howbase

,

. , ,
- : ,
- .

showpoi nt

,


.

showpos

,

'+' .

scientific,
fixed

scientific,

. intemal, -
.

/ '

141

fixed ,


precision .
,

:
,
4
.

-

ios: :floatfield.

,

,

- .

u p pe rcase

l o n g flags()

r .

l o n g f l a gs( long )


r .

long o l d Fiags cout.flag sQ:


11 -
cout.flags( o l d Fiags ):
=

. . .

. . .

, , , precision ,
, uppercase,

142

++

l o n g setf( long b itFi ags )

m
.

long o l d Fiags = cout . setf{ ios : : s howbase );

l o n g setf( l ong bitFiags,


long bitField )

,
m

.

ios::adjustfield, ios : : basefield ios: :floatfield.

cout.setf( ios : : scientific, ios : : floatfield ):

l o n g u nsetf( long )

cout. u n setf{ ios : : s howbase & ios: : u ppercase ):

i os& setiosfl ags( long )

, flags ,

, setiosflags() - .

r setf O ,
.
ios : : scientific,
**

, ios : : fixe d .

setiosflags O
ioman i p . h .

143

cout setiosflags( i os : : s howpos );

i os& resetiosfl ags( long )

, unsetf () ,
*
, resetiosflags () - n .

cout resetiosflags( ios: : s howpos );

c h a r fi l l ( char )

-
-n.
- (.
width () ) .

ostrea m & setfi l l ( c h a r )

, fill ,
,
**
setfill O -

c h a r fi l l ( )

-.

i nt w i dth( i nt m i n i m u m )


.
.

resetiosflags O

iomanip. h .
**

setfiii O t
iomanip . h .

144

++


,
-.
, r .

i nt w i dth()

i os& set w ( i nt s i z e )


,
, , *
.

const i nt l i neS ize = 80 ;


char l i n e[ l i neS ize ]:
11 . . .

whi le( c i n
1/...

i os&
i os&
i os&
i os&

setw( l i neS ize )

l i ne )

de c ( i os& )
oct( i os& )
hex( i os& )
setbase( i nt )

,

. setba s e ( i n t ) -

setw O ,
iomanip.h.

145

l nt n 1 99 1 ;
cout << II Dec i m a l : < < n
<< oct << Octa l : < < n
<< hex H exadec i m a l :
=

11 ,

11 ,

11

endl;

1 1 . . .
Decimal: 1 99 1 , Octal: 3707, Hexdecimal : 77

i nt d , , h ;
c i n d oct hex h ;

cout << setbase( 1 6 ) :

i nt prec i s i o n ( i nt )

,
,
.
.

i os& setprec i s i o n ( i nt )

, precisio ,

, setprecisio O - .

setase O ,
r iomanip.h .

setprecision
r iomanip . h.

146

++

i nt p rec i s i o n ( )

,
.


++ (
++) . ,
,
.

r;

ctype . h . . .

, .
: int . ( char )
i sa l n u m
isal pha
lsascii
i scntrl
i s d lg it
i s g raph
i s lower
l s p rl nt
i s p u nct
l s s pace
i s u pper
lsxd l g it

-
-
- ASCII ( ,
1 28)
-
( 1 27)
-
- ,

- m
- ( )

- ,
,
,
-
- m
-

: char . ( char )

++

148

toasc i l
tolower

_toupper

pem
'

tolower

,
(isupper( ) ? _tolower( > : )

tou pper

,
(islower( ) ? _toupper( ) : )

str i ng . h . . .

ASCII

,
,
.

i nt str l e n ( const cha r s )

s,
-.

char *message " H e l l o worl d ! " ;


i nt lenght strlen( message ) ; 1 1 lenght
=

12

c h a r strcpy( char to,


const c h a r from )
c h a r strncpy( c h a r to,
const c h a r from, i nt l i m it )

, from, ,
to. to.
, to, -

149

strcpy () , limit .
.

char *message "You whant lt when? " ;


char buf[20];
strcpy( buf, message ) ; 11 message b u f
=

c h a r strcat( char to1


const char from )
c h a r strncat( char to1
const c h a r from1 i nt l i m it )

, from,
, to. to.
, to,

.
strncat O ,n , .
.

char name[20] " H u m pty" ;


strcat( name, " D u m pty" ) ;
=

i nt strcmp( const char s 1 1


const char s2 )
i nt strnc m p( const char s 1 1
const char s21 i nt l i m it )

'

1 50
-1,

++
+ 1 ,

s l ,

, s2.

strncp () , liit .

for( i nt fi rst = , last = N ; fi rst <= last; )


{
i nt i ndex = ( fi rst + last ) 1 2 ;
i nt res u lt = strc m p( word , d ictionary[index] );
if( res u lt < ) last i n dex - 1 ;
else
if( res u lt > )
fi rst = i ndex + 1 ;
else b reak ;
}
=

c h a r strc h r( const c h a r s, c h a r )
c h a r strrc h r( const c h a r s, c h a r )

s .
s.
.
strrchr() , ()
s.

c h a r strpbrk( const c h a r s,
const c h a r set )

,
set, s. r
s.
.

1 51

i nt strspn( const char s,


const c h a r set )
i nt strcspn( const char s,
const c h a r set )

s, ,
set.
r , set.
strcspn () ,
set. r ,
r set.

char *s "2000 North Naperv l l le Road " ;


l nt n strspn( s , 0 1 2 345 6789 ) ; 1 1 n 4
=

"

"

c h a r strtok( const c h a r s,
const char set )

, ,
set, . r
,
li,
, .
strtok() .

.
.
strtokO ,
, r -

1 52

++

,
strtokO
,
.

vold ToWords( reg l ster char *s )


{
reg lster char * word ;
whlle( word = strtok( s , " ) )
{
cout word en d l ;
s = ; 1 1
}
}
"

1 i m its h

1 1


( ,
ANSI) .
-

C HAR_B IT

S C HAR_M I N

- 1 27

signed char

S C HAR_MAX + 1 2

signed char

C HAR_M I N

SCHAR_MIN

hr

UCHAR_MAX
SCHAR_MAX

hr

CHAR_MAX

LE N 1

, .

1 53

S H RT_M I N

-32767

short

S H RT

+32767

shrt

U S H RT 65535

unsigned short

I NT M I N

-32767

int

I NT

+32767

int

U I NT_MAX

65535

unsigned int

LONG_M I N

-2147683647

lng

LONG_MAX

+2 147683647

lng

U LONG_MAX 4294967295

unsigned long

math . h . . .

.
(sin, cos ..)
.
, , ,
doule.
doule.

1 54

++

acos
as ln
atan
ata n2(y,x)
cel l
co s
cosh

fabs
floor
fmod(x,y)
log
log 1 0
pow(x,y)
sin
slnh
s q rt
tan
tan h

il

std a rg . h

1 . 1

,

r .
:
void va_start ( va_list, - )
void va_arg ( va_list, )
void va_end ( va_list )
va_start .,
-- ,

va_arg

1 55

I' .
va_ed .

vold N u m P rl nt( con st char * format . . . )


{
va_l lst a rg ;
va_sta rt( a rg , format );
for( char * format; *; ++ )
{
lf( *
'%' )
switch( *++ )
{
case ' d ' :
l nt l v a l v a a rg( a rg , i nt );
cout l va l ;
b reak;
case ' f' :
d o u e dval va_a rg( a rg , d o u e ) ;
cout dval ;
b reak;
}
else
cout << *;
}
va e n d( a rg );
}
=

==

std l i b . h . . .

,
.

1 56

++

vo i d ex it( i nt )

.

.
,
.

vo i d a bort()

n
..... ,

i nt ato i ( c h a r )

l o n g ato l ( c h a r )

d o u e atof( c h a r )

.
retum mainO ex1 t O
, .

, , , r,
- .

titO , .

, .

ASC I I
ASCI I , , .
, , 32,

( , Ctrl ) .
Dec Oct
NUL
@

000 00
SOH
1

00 1 0 1
2

3
4
5
6
7

002
003
004
005
006

02
03
04
05
06
07
08
09

STX

ENQ

BEL
BS

"F

007
010
01 1

10
11

0 1 2
0 1 3

VT

12
13
14

0 1 4
0 1 5 OD
0 1 6

CR

so

15
16

0 1 7 OF
020 1 0

SI

17

02 1

11

DC 1

LF
FF

DLE

1 58

++

18

022 1 2

"R

DC2

19

023

13

"S

20

024 1 4

"

DC4

21

025 1 5

"U

NAK

22
23

026 1 6
027 1 7

"W

SYN

24
25
26
27
28

030
03 1
032
033
034

18
19
1
1
lC

29

035 1 D

"J

GS

30

036 1

31

037

Dec
32
33
34
35
36
37
38
39
40
41
42

Oct
040
04 1
042
043
044
045
046
047
050
05 1
052

lF

20
21
22
23
24
25
26
27
28
29
2

"

SUB

"[

ESC

"\

FS

1
2
3
4

CAN

RS
us

Dec
() 80
81
!
82
#
83
84
$
85
%
&
86
87
88
(
)
89
*
90

Oct
1 20
121
1 22
1 23
1 24
1 25
1 26
1 27
1 30
131 '
1 32

50
51
52
53
54
55
56
57
58
59
5

R
s

u
v
w

ASCII
Dec
43
44
45
46
47
48
49
50
51
52
53

54
55
56
51
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
15

76
77
78
79

Oct
053
054
055
056
057

2
2
2D
2
2F
30
06 1 3 1
062 32
06 3 33
064 34
065 35
066 36
067 3 7
070 38
07 1 39
072
07 3
074 3
015 3D
07 6 3
077 3F
1 00 40
101 41
1 02 42
1 03 43
1 04 44
1 05 45
1 06 46
1 07 47
1 10 48
1 1 1 49
1 1 2 4
1 1 3 4
1 1 4 4
1 1 5 4D
1 1 6 4
1 1 7 4F

Dec
91
92
93
94
95
1

96
97
1
2
98
99
3
4
1 00
101
5
102
6
1 03
7
104
8
9
1 05
106
107
<
108
1 09
>
1 10
111
?
1 12
@
1 13

1 14

1 15

F
G

1 16

1 17
1 18
1 19
1 20
121
1 22

1 23

1 24
1 25
1 26
1 27

Oct
1 33
1 34
1 35

1 36
1 37
1 40
141
1 42
1 43
1 44
1 45
1 46
1 47
150
151
152
1 53

1 59

5
5
5D

5
5F
60
61
62
63

64
65
66
67
68
69

1 54
1 55 6D
1 56 6
1 51 6F
1 60 70
161 71
1 62 72
1 63 7 3
1 64 74
1 65 1 5
1 66 76
1 67 77
1 70 78
1 7 1 79
1 72 7
1 7 3 7
1 74 7
1 15 7D
1 76 7
1 77 7F


[
\
]

'

f
g
h

k
1
m

r
s

t
u

}
DEL

: ++

10

10
10
11
12

12
12
13
13
14
15
15

16
16
17
17
17

18
19
19

20
21
21
23
24
26
26
27
27

break
continue
retum
goto
if
switch
while
do
for


volatile

main

27
27
28
28
28
29
30
30
31
32
34
34
34
36
36

36
37
38
40
41
43
44
46
47
48
48
50
52
53
53
55
57
57
59
60
60


-
-
.

-
-

63
66
71
72
78

-

.

85
86
88
89

1 00
1 02

79
81
82
85

89
92
94
94
96
1 00

1 04
1 05
1 05
1 08
1 09
1 10
1 10
111
1 12
113

New De1ete

161

1 14
1 15

1 18

1 26


r IQ
r



/

1 26
1 27
1 28

1 32
1 36
1 37
1 38
1 39
1 47


ASCII

1 57

1 60

:.

+ +

. .

. .

. .

. . ,
. .

1
1 .06.93 . 8.06.9. 84 1 08 / 32.
. '"". . . . . 8,38.
. .

&g(J,

.- . .

7, ::,'}.

40000 . .

NQ 3-2 0 7

- >>
: 252055, -55, / 1 00.
. / (044) 441 -9766.

: 254 l l 9, - 1 1 9, . r, 3 8 - 44.

: :
*
;
*
r Windows;
*
r;
*
- ;
*
r
*
;
*
r;
*
;
:
.

" r"

: ,
- , ++, , .
:

.
"r Windows"


Windows. :
,
,
Windows.
" r"

:
.
,
.


.
, ,
,
.

" - "
m
,
.
" "

,
CASE- ,
,
r.
" "

,
.
m ,
,
m
. l
. ,

.

,
.
,
,

.

.

. ,

,

.

" "

, ,
..

,
.
-

.
.
" "
,

.
r
.
,
.
m,
.. , ,
- .
01. /
.
.,

. '
, . : ,
252055, . -55, / 100, .
.t . /