0

Problems with my inheritance program

to test my knowledge of inheritance and Constructors, I've created three classes, a member, a student and a teacher. on the student and teacher constructors, they simply call the member constructors. only problem is, even if I pass in any values, the default empty constructor will run. what have I done wrong? https://code.sololearn.com/ceyjGqlUSWo2/?ref=app

19th Aug 2017, 12:37 PM
X-1
X-1 - avatar
1 Answer
0
from what I can see, when you called the constructor for student, you called the member constructor inside the student constructor, thus making another member object different from the student object you just created. You should refer to the member constructor0 using the colon symbol : student(string fname, string sname, string id, int grade) : member(fname, sname, id){ this->grade = grade; } Please correct me if I got anything wrong.
20th Aug 2017, 12:51 PM
Joni Jimenez
Joni Jimenez - avatar