.


:




:

































 

 

 

 





, .

, . . . .

. , , . , . , . "" .

, "" , .

:

class A

{ public:

void f1();

void f2();

}

A *pa;

BB *pb;

B x; // x- B

pa=&x; // .

pa->f1(); // .

. , , .

pb=(B*) pa;

pb->f1(); // B::f1();

pb->f2();

. - . , .

.

class A { int x;...} class B extends A { int y;...} B b = new B();A a = b; // : B => A upcasting downcasting. (upcasting) ( ) (). . (. ). , .

(downcasting) .

 

 


. . .

. , : , , , . ' , .

-

T::T(const T&){/* */}

,

-

-

-

, . .

, , , , :

date date2 = date1;

, :

- - , , ;

- - , , return , .

:

- dat2 ;

- ;

- , , .

-:

- dat1 ;

- ;

- - return.

, -, . , . - -:

class string

{

char *Str;

int size;

public:

string(string&); //

};

string::string(string& right) //

{ //

s = new char[right->size];

strcpy(Str,right->Str);

}

, - , , .

. , , .. , , , .

, . .

x = 2; // x 2cond = x < 2; // cond true, x 2, // false3 = 5; // , 3

. . , , .

int x = 0;x = 3;x = 4;x = x + 1;

x 0. x 3, 4 5. -, . , . x + 1, x 4. x + 1 5. (, , ) x 5.

. . , :

z = (x = y + 3);

x z y + 3.

. , ++ : ++ ( ) -- ( ). : . .

int x = 0;++x;

x 1.

--x;

x 0.

int y = ++x;

x . ++ x, .. y 1.

int z = x++;

. x 1. x 2. . , z 1. , , .

( ++), " ". , :

x = x + 5;y = y * 3;z = z (x + y);

++ :

x += 5;y *= 3;z -= x + y;

.. oper= , oper, oper. , .

 


. . . .





:


: 2016-07-29; !; : 909 |


:

:

, ,
==> ...

1479 - | 1406 -


© 2015-2024 lektsii.org - -

: 0.012 .