So i have created this example to simplify the question. I have 3 classes where 2 inherits from the same one.
the problems are as described down bellow. with the main errpr beeing uninitialized member variables and non standard syntax error requiring a pointer
MAN CLASS
class Man {
private:
int age;
public:
string name;
Man() { //constructor
this->age = 0;
this->name = "default";
cout << "created Man in default constructor" << endl;
}
Man(string, int);// constructor
};
Man::Man(string, int) {
this->name = name;
this->age = age;
cout << "created Man: " << this->name << endl;
}
TEACHER CLASS
class Teacher : Man {
public:
string field;
Teacher(string, string) {
this->name = name;
this->field = field;
cout << "created Teacher: " << this->name << endl;
}
Teacher() {
this->field = "not declared";
cout << "created Teacher in default constructor" << endl;
}
string getName() {
return name;
}
};
STUDENT CLASS
class Student : Man {
public:
Teacher tutor;
int age;
Student(string, Teacher, int) {
this->name = name;
this->tutor = tutor;
this->age = age;
cout << "created student: " << this->name << " teacher is: " << this->tutor.getName << endl;
}
};
Main
int main(){
Man erlichBlachman(12, "Erlich Blachman");
Teacher richardHendricks("Richard Hendricks", "compression algorithms");
Student dinesh("Dinesh", richardHendricks, 27);
Student gilfoyle("Gilfoyle", richardHendricks, 32);
}
ERRORS
Error (active) E1696 cannot open source file
Warning C26495 Variable 'Man::age' is uninitialized. Always initialize a member variable (type.6).
Warning C26495 Variable 'Student::age' is uninitialized. Always initialize a member variable (type.6).
Warning C26495 Variable 'Man::age' is uninitialized. Always initialize a member variable (type.6).
Warning C26495 Variable 'Student::age' is uninitialized. Always initialize a member variable (type.6).
Error C3867 'Teacher::getName': non-standard syntax; use '&' to create a pointer to member
Error C2664 'Man::Man(Man &&)': cannot convert argument 1 from 'int' to 'std::string'
added error log in text format on request.