According to the class hierarchy of FIG programming, objects belonging to the definition of the object t1 c1 score and teacher's class, are input each data member values before displaying these data.
![7411425-038e8cee4fe200fa.png](https://upload-images.jianshu.io/upload_images/7411425-038e8cee4fe200fa.png)
#include "stdafx.h"
#include
#include
using namespace std;
class person{
private:
string name;
int ID;
public:
string getName() {return name;}
int getID() {return ID;}
person(string na, int I) : name(na), ID(I) {}
virtual ~person(){}
};
class stud{
private:
string addr;
string tel;
public:
string getAddr() {return addr;}
string getTel() {return tel;}
stud(string _addr, string _tel) :addr(_addr), tel(_tel) {}
virtual ~stud() {}
};
class score{
private:
float eng;
float math;
public:
score(float _eng, float _math) :eng(_eng), math(_math){}
virtual ~score() {}
float getEng() { return eng; }
float getMath() { return math; }
void print(){cout << "English:" << eng<<" Math:"<
};
class teacher : public person{
private:
int degree;
string dep;
public:
int getDegree() { return degree; }
string getDep() { return dep; }
void print(){cout << "Name:" << person::getName()<< "\tID:" << person::getID() <<"\tDegree:" << degree << "\tDepatrment:"<< dep << endl;}
teacher(string na, int I, int _degree, string _dep) :person(na, I),degree(_degree), dep(_dep) {}
virtual ~teacher() {}
};
class student : public person{
private:
int old;
int sno;
stud info;
score scores;
public:
int getOld() { return old; }
int getSno() { return sno; }
student(string na, int I, int _old, int _sno, string _addr, string _tel,int _eng, int _math)
:person(na, I), info(_addr, _tel), scores(_eng, _math), old(_old),sno(_sno) {}
virtual ~student() {}
};
int main ()
{
score s1(120, 130);
teacher tea("Wang wei", 10086, 2, "House");
s1.print();
tea.print();
return 0;
}
Reproduced in: https: //www.jianshu.com/p/d69fbf41f6ce