.


:




:

































 

 

 

 





  .
 
   
   
1  
   
1.1 ++  
   
1.2  
1.3 ++  
1.4 /  
1.5  
1.6 : ѻ  
1.7  
1.8  
1.9  
1.10  
1.11  
1.12  
1.13  
1.14  
1.15  
1.16  
1.17  
1.18  
1.19  
1.20  
1.21  
1.22  
1.23  
1.24  
2 -  
2.1 -  
2.2  
2.3 this  
2.4  
2.5  
2.6  
2.7  
2.8  
2.9  
2.10  
2.11  
2.12  
2.13  
2.14  
2.15  
2.16 : ++  
 

, ++. : , , - .

.01.02 09.02.03 , 2 3 .

, .


1

 

1.1

++

 

++ :

0 9

:.,:;!? + - * / < > = % \ | & # ~ ^ { } [ ] ()

: ,

:

()

(, , , )

.

(, , ). , .

, . , . .

. , .

 

:

;

, .. , , , ;

, .

. , , , , (iMaxLength). (max_length).

, . , . :

asm dynamic_cast namespace switch volatile

auto else new mutable wchar_t

bool enum operator template while

break explicit private this

case export protected throw

catch extern public true

char false register try

class float reinterpret_cast typedef

const for return typeid

const_cast friend short typename

continue goto signed union

default if sizeof unsigned

delete inline static using

do int static_cast virtual

double long struct void


. 1.1.

1.1 C++

: , , . 8, 0, 199226
: , (0 7). 01, 020, 07155
: 0x 0X, (0 9, A, B, C, D, E, F). 0x, 0x18, 0X00FF
: [ ].[ ] , , . 5.7,.001, 35.
: [ ][.][ ]{|}[+|-][] , , . 0.26,.11-3, 510
, . , , *, db, \0, \n, \012, \x07\x07
, . Vasia, \t r = \0xF5\n

. ( ), . 10, .

- (: -218, -022, -0x, -4.8, -0.14).

. ( ) . , .

, , char. int, .

( ) - - \0( ). - . , . (, ), () . 1 . .

(escape-) , \. . 1.2 . , \, .

 

 

1.2 - C++

\ ,
\b
\f
\n
\r
\t
\v
\\ ,
\
\
\?
\055
\0xdd

 

, , , , : \\.

0 255. , .

, , .

, , . .

 

,

\

, \

,

, . - . [ ], () ?: , .

, .

().

++ . , C++, .

:

// ,

/* */

, . - , .

 

1.2

 

, , , :

;

, ;

, ;

, .

.

C++ . ,.. . . , , , , , , .

++ :

int ()

bool ()

char ()

wchar_t ( )

float ()

double ( )

(), . .

:

short ()

long ()

signed ()

unsigned ()

(int)

int : 16- 2 , 32- 4 . short ( short int) 2 , long ( long int) 4 .

. signed, (0 , 1 ), unsigned ( ).

( signed ). short int, long int, signed int unsigned int short, long, signed unsigned .

(char)

char , . ASCII 1 . char , ( 0 255). char, , .

(wchar_t)

wchar_t , 2 (, Unicode). wchar_t L, , LGates.

(bool)

true false ( ). bool 1 0 . 1 . bool true, false.

(float, double long double)

. , 1.0, 2.0. 1, .

float 4 (32 ): , 23 , 8 .

double 8 (64 ): 11 52 . long ( long double) , 10 (80 ): 11 68 .

, . , float long int, - ( 1.3).

1.3 IBM PC

()
bool true false  
signed char -128... 127  
unsigned char 0... 255  
signed short int -32 768... 32 767  
unsigned short int 0... 65 535  
signed long int -2 147 483 648... 2 147 483 647  
unsigned long int 0... 4 294 967 295  
float 3.4e-38... 3.4e+38  
double 1.7e-308... 1.7c+308  
long double 3.4e-4932... 3.4e+4932  

 

ANSI , , :

sizeof (float) < sizeof (double) < sizeof(long double)

sizeof (char) < sizeof (short) < sizeof (int) < sizeof(long)

<limits.h> (<climits>), <float.h> (<cfloat>), numeric_limits.

void

void. . , , , .

. , .

int. L, l (long) U, u (unsigned). , 32L long 4 . L U (0x22UL 05Lu).

double. F, f (float) L, l (long). , 2E+6L long double, 1.82f float.

 

 

1.3

++

 

++

. . 1.1 .

 

1.1 .

- .

( ) , , .

- , , .

, , .

- , , , . , .. , .

, .

, . .

, . , .. .

1.2 C++.

() , .

 

1.2 - C++

 

++

C++ , .

. #. .

#include, , , . :

#include <_>

#include _

. .h, (header file).

, , . , stdio.h / printf, scanf . .

, : #include < stdio.h >.

, .

. ( ). , . , ( ).

:

([]) {

}

, . , void. , .

main. . , . main void ( ), int. main int.

, main, .

 

1.4

/

C++ / : , , / ++.

- ()

printf. :

printf (_, _);

( ), , . .

( ). , .

%. :

% ;

%s ;

%d %i ( int);

%u ( unsigned);

%f ;

% %E .

l (long) h (short):

%ld long int;

%hd short int;

%lf long double.

:

float m,p;

int k;

m = 84.3;

k = -12;

p = 32.15;

printf ("m=%f\tk=%d\tp=%e", m,k,p);

:

m=84.299999 k=-12 p=3.21500e+01

\t .

: . , , . % .

:

printf("m=%5.2f\tk=%5d\tp=%11.4", m,k,p);

:

m=84.30 k= -12 = 3.2150+01

, , .

scanf. , , . :

scanf (_, _);

scanf() . ( &).

, , . scanf , .

, , . Enter . .

c, %,

*[ ] []

. , printf. , , . . .

printf() scanf() stdio.h, .

:

#include <stdio.h>

int i, j;

void main () {

printf ( \n);

scanf (%d%d, &i, &j);

printf ( %d %d, i, j);

}

stdio.h. i j. . printf \n. scanf i j. printf , .

-

++ / : cin cout . cin . >>. cout . <<. ( ) .

cin cout iostream.h.

:

#include <iostream.h>

void main () {

int i, j;

cout << << endl;

cin >> i >> j;

cout << << i << <<j;

}

>> << . endl \n.

/ . . . , .

 

1.5

 

. , .

. , , .

, .

. .

.

.

, . . .

:

[ ] [const] []

auto, extern, static register.

const , . , .

- . :

- =

- ()

.

, .

:

short int = 1; //

const char = ђ; //

char s, sf = f; // sf

char t(54);

float = 0.22, x(3), sum;

, .

, , . , .

, .

.

, , , .

, , , .

. , .

( ) ( ).

, .

. , . , . , , , , ::.

:

auto . , . , . . , , .

extern , ( ). , , . , extern .

static . . , . . , .

register auto, . , auto.

:

int a; // 1

int main(){

int b; // 2 b

extern int x; // 3

static int ; // 4

= 1; // 5

int a; // 6

= 2; // 7

:: = 3; // 8

return 0;

}

int x = 4; // 9

a . , . , 6-8, , .

b , , : b , , .

, . .

(, ).

, , , , , , 1, l ( L) I ( i). . , ( ), , , .

. , , , . C++ . 3 , .

, , , .

( ), ( ) ( ). .

( 1) ++ ( 1) --

- , , - . , . , .

:

#include <stdio.h>

int main(){

int x = 3, = 3;

printf ( : %d\n, ++x);

printf ( : %d\n, y++);

printf ( : %d\n, x);

printf ( : %d\n", );

return 0;

}

:

: 4

: 3

: 4

: 4

L- (L-value). , , . , (Left) , . L-.





:


: 2016-11-12; !; : 1053 |


:

:

, .
==> ...

1550 - | 1347 -


© 2015-2024 lektsii.org - -

: 0.185 .