You are viewing a single comment's thread. Return to all comments →
static int cur_idstu; static int cur_idprofe;
class Person
{ public:
string name; int age;
virtual void getdata(){}
virtual void putdata(){} }; class Professor: public Person{
int publications,cur_id; void getdata() { cur_id=++cur_idprofe; cin>> name >> age >> publications; } void putdata() { cout << name <<" "<< age <<" "<< publications <<" " <<cur_id <<endl; }
}; class Student: public Person{
int marks[6];int cur_id; void getdata() { cur_id=++cur_idstu; cin>> name>> age; for(int j=0;j<6;j++) { cin>> marks[j]; } } void putdata() { int sum=0; cout<< name <<" "<< age ; for(int i=0;i<6;i++) { sum+=marks[i]; } cout<<" " <<sum<<" "<< cur_id<<endl; }
};
Seems like cookies are disabled on this browser, please enable them to open this website
Virtual Functions
You are viewing a single comment's thread. Return to all comments →
static int cur_idstu; static int cur_idprofe;
class Person
{ public:
virtual void getdata(){}
virtual void putdata(){} }; class Professor: public Person{
}; class Student: public Person{
};