.


:




:

































 

 

 

 


static const




 

, .

(1, 2, 3); (1, 2, 3) ( ). this.

, .

:

 

class_type:: _

class_type:: _ ()

 

, .

, const, , :

const class_type * const this.

 

 

 

, . const_cast mutable.

 

 

, , . .

- , .

 

:

 

class type {

public:

void f1 (int b) {x = b; y = 0;} // x y

void f2 (double k) {y = k*x;}

static void f3 (int c) {z = c;} // z

int f4 () const {return x+y+z;} // f4 x, y, z

friend int f5 (const type & t); // type , f4

private:

int x; //

int y; //

static int z; // ,

};

int type:: z = 10; //

main()

{ type w1,w2; //

w1.f1(100); // w1: x = 100, y = 0, z = 10

w2.f1(200); // w2: x = 200, y = 0, z = 10

w1.f2(0.5); // y w1

w2.f2(0.8); // y w2

type:: f3(300); // f3 z w1 w2

cout <<w1 = <<w1.f4() // x, y, z w1

<<w2 = <<f5(w2)<<endl; // x, y, z w2

}

 

 

, () , (. III). . , , (, , , ..).

.

 

1. . .

2. ?

3. ?

4. , .

5. this?

6. ?

7. static const?

8. , ?

9. ?

 

V

: ; ; .

 





:


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


:

:

, .
==> ...

1554 - | 1328 -


© 2015-2024 lektsii.org - -

: 0.031 .