. , , , , , .
:
- friend. , this ;
- . ; ;
- .
class monstr;
class hero {
public:
void rill (monstr &);
};
class monstr {
friend int steal_ammo (monstr &);
friend void hero:: kill (monstr &);
};
int steal_ammo (monstr &M) { return --ammo;}
void hero:: kill (monstr &M) {M.health=0; M.ammo=0;}
kill hero, steal_ammo .
- , friend.
class hero {
friend class mistress;
};
class mistress {
void f1 ();
void f2 ();
};
f1 f2 hero.
!!! friend .
, , . , :
- , ;
- main;
- , , delete.
(~), . :
- ;
- const static;
- ;
- .
, .
, , .
. monstr name (. ).
monstr:: ~ monstr () {delete [ ] name;}
, :
Monsr *m;
m -> ~ monstr ();
.
|
|
++ , . . . , :
..*?::: # ## sizeof
(-) :
- , ( ), ;
- ;
- - ;
- - ( =);
- - static.
- : , , . , , .
- operator, :
operator ( ) { }