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