You are viewing a single comment's thread. Return to all comments →
static int cur_ids; static int cur_idp;
class Person { public: string name; int age;
virtual void getdata(){} virtual void putdata(){}
};
class Professor:public Person { public: int publications; int cur_id;
void getdata(){ cin>>name>>age>>publications; cur_id=++cur_idp; } void putdata(){ cout<<name<<" "<<age<<" "<<publications<<" "<<cur_id<<endl; }
class Student: public Person { public: int marks[6]; int cur_id;
void getdata(){ cin>>name>>age; for(int i=0;i<6;i++) { cin>>marks[i]; } cur_id=++cur_ids; } void putdata() { int sum=0; for(int i=0;i<6;i++) { sum=sum+marks[i]; } cout<<name<<" "<<age<<" "<<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_ids; static int cur_idp;
class Person { public: string name; int age;
};
class Professor:public Person { public: int publications; int cur_id;
};
class Student: public Person { public: int marks[6]; int cur_id;
};