.


:




:

































 

 

 

 





 

, : .

, ( ) .

. " ". "" "". " " .

 

class Worker {

public:

int ID_profession; //

char* Name; //

};

class Student {

public:

int ID_university; //

char* Name; //

};

class Student_Worker: public Student, public Worker {... };

 

 

Student_Worker He;

...

He.ID_profession; //

He.Name; //

 

, .. , , .

 

He.Worker:: Name; //

 

, - .

. , , , , , . "".

 

class Person {

public: char* Name; //

}

 

class Worker: public Person {

public: int ID_profession; //

}

 

class Student: public Person {

public: int ID_university; //

}

 

Student_Worker . 4.1.

 

 

. 4.1 Student_Worker

 

, .. -.

 

He.ID_profession; //

He.Name; //

He.Person:: Name; //

He.Worker:: Name; //

He.Student:: Name; //

 

, , . Student_Worker Name, Person. Student_Worker, 4.2.

 

 

. 4.2 Student_Worker

 

. ( ) . .

 

class Person {...};

class Worker: public virtual Person {...};

class Student: public virtual Person {...};

class Student_Worker: public Student, public Worker {... };

 

 

. Controller . Plan.

 

class Plan;

class Controller{

...

void process (Plan&);

...

};

 

Plan - process; , Controller Plan.

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

-. . , - .

 

 

. , , . :

 

class IntStack {

int stack[100];

...

};

class ControllerStack {

Controller* stack[100];

...

};

 

, , , . , :

 

class Stack {

void* stack[100];

...
};

 

. , , .

. , . ++ .

 

template <class ype> class Stack {

ype stack[100];

...

public:

void push (ype);

();

...

};

 

template < class ype > ype , .

. , .

:

 

typedef Stack < int > IntStack //

typedef Stack < Controller* > ControllerStack //

//

IntStack IS; //

ControllerStack CS; //

 

IS CS , . Stack.

. C++ -, Controller, .

++ , . , .

 

template <class ype > ype max(ype x, ype y){

return (x > y)? x: y;

};

 

.

 

int i, j, k;

double a, b, c;

...

k = max <int> (i, j);

c = max <double> (a, b);

 

, , ">".

 





:


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


:

:

80% - .
==> ...

778 - | 728 -


© 2015-2024 lektsii.org - -

: 0.02 .