- () , , .
- :
1) public, private, protected .
2) (static). , .
3) const. . , , .
4) .
.
( ) ( )
1) ;
2) ;
, , , , .
24.5. - ( ) , - .
-:
1) .
2) public, protected, private .
3) .
4) , .
5) () this ( . , , ( )).
6) static.
7) const ( )
8) ( )
.
static . , .
.
. , this.
.
class A {
private:
Static int count;
Public
static void inccount(){count++};
};
A::int count;
void f(){
A a;
//a.count++;// !!!!
a.inccount; //
.
|
|
. static ( ) , . , ( Microsoft Visual Studio).
. . , :
class MyClass {
Const int ID;
public:
MyClass(aID): ID(aID) { }
, , .. :
MyClass(aID) {ID = aID; }
.
. .
1) const ;
2) ;
3) ;
4) ( ).
: , .