.


:




:

































 

 

 

 


, ,




++ , , , struct, union, enum.

//C

enum day{sun,mon,tue,wen};

struct path{char str[30];

enum day Week;}

struct path Link;

//C++

enum day{sun,mon,tue,wen};

struct path{char str[30];

day Week;}

path List;

, .

struct Goods{

char *name;

union{double d, long l, int i)};

};

++ :
- ;
;
;
;
;
;
;
;
;
.

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


. .

, . .

++ 2 : , , . . . . - . .

3 : public, private protected. , .

int var;

class Ex

{

public:

f(){var =0};

private:

int var; //

}

.

class Point2D

{

double x,y;

public:

Point2D(double x, double y)

{

Point2D::x=x;

Point2D::y=y;

}

}

exteen int count;

struct POINT;

class Point2D;

, .. , .


static.

  1. .
  2. , . .
  3. , . ++ new delete.

, - , . , , , . , , static.

class Point2D

{

double x,y;

static int count;

public:

Point2D(double x, double y)

{

x=_x;

y=_y;

count++;

}

~Point2D()

{

count--;

}

};

//point2d.cpp

int Point2D::count;

. - . .

//

cout<<Point2D::Count<<\n;

, -, .

static int GetCount()

{

return count;

}

cout<<Point2D::GetCount();

, this .

: . , .

 

 






:


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


:

:

.
==> ...

1882 - | 1675 -


© 2015-2024 lektsii.org - -

: 0.009 .