.


:




:

































 

 

 

 


. . .




.

, , - .

const monstr& operator = (const monstr &M)

{if (&m==this) return *this;

if (name!= NULL) delete[] name;

{name=new char[strlen(M.name)+1];

strcpy(name, M.name);}

else name=NULL;

health=M.health; ammo=M.ammo;

return *this;}

monstr A(10), B, C; C=B=A;

.

:

operator _();

monstr:: operator int() {return health;}

monstr:: operator char*() {return name;}

...

monstr Vasia;

cout<<(int) Vasia<<(char*) Vasia;

.

class Vect

{private:

int *p;

int size;

public:

Vect(int n)

{size=n;

p=new int[size];}

~Vect() {delete[] p;}

... //

...

int & operator[] (int);};

int & Vect:: operator[] (int i)

{if (i<0||i>=size)

{cout<<" ";

return p[0];}

return p[i]}

void main()

{Vect a(10);

...

cout<<a[5]<<"\n";

cout<<a[12]<<"\n";} // .

. . .

,

-

- , :

1) private ,

2) protected

3) public

private private protected public private private
protected private protected public protected protected
public private protected public protected public

- ,

- :

) ,

) , ,

)

) ,

- ,

- , , . .

. .

monstr *p;

p=new daemon;

virtual void draw(int, int, int, int);

- , , ,

-

- static

- , (virtual void func(int)=0;)

X(vtbl)

virtual func1()

virtual func2()

virtual func3()

X

void *vtpr;





:


: 2016-03-27; !; : 423 |


:

:

.
==> ...

1510 - | 1341 -


© 2015-2024 lektsii.org - -

: 0.011 .