.


:




:

































 

 

 

 





static .

, , , . , .

( ) , :

class A

{

public:

static int count;

}

...

A::count = 0;

, :

/* */

A *a, b; * cout << A::count << a->count << b.count;

, , private, , . .

, , sizeof. , .

- . , .

, this. , - , , , .

(const) (virtual).

 

, . .

, , friend. , this . "" .

. , .

, monster. kill hero, steal_ammo . monster.

class monster; //

class hero

{

...

void kill(monster &);

};

class monster

{

...

friend int steal_ammo(monster &);

/* hero */

friend void hero::kill(monster &);

};

int steal_ammo(monster &M){return --M.ammo;}

void hero::kill(monster &M){M.health = 0; M.ammo = 0;}

- , friend. mistress hero:

class hero{

... friend class mistress;}

class mistress{

... void f1();

void f1();}

f1 f2 hero ( friend) .

friend . , , , .

 

- , , . , :

  • - , ;
  • - main;
  • , , delete ( ).

. delete. delete[] .

(~), . :

  • ;
  • const static;
  • ;
  • ;
  • ; , new .

, .

, , - , -, . .

:

monster::~monster() {delete [] name;}

 

++ , . , . . , ++, :..*?::: # ## sizeof.

(-) :

  • , ( ) ;
  • ;
  • - ;
  • - ( =).

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

- operator, :

operator ( ) { }





:


: 2016-12-05; !; : 280 |


:

:

, .
==> ...

1475 - | 1416 -


© 2015-2024 lektsii.org - -

: 0.014 .