fork download
  1. #include<iostream>
  2. using namespace std;
  3. class Person {
  4. // Data members of person
  5. public:
  6. Person(int x) { cout << "Person::Person(int ) called" << endl; }
  7. };
  8.  
  9. class Faculty : public Person {
  10. // data members of Faculty
  11. public:
  12. Faculty(int x):Person(x) {
  13. cout<<"Faculty::Faculty(int ) called"<< endl;
  14. }
  15. };
  16.  
  17. class Student : public Person {
  18. // data members of Student
  19. public:
  20. Student(int x):Person(x) {
  21. cout<<"Student::Student(int ) called"<< endl;
  22. }
  23. };
  24.  
  25. class TA : public Faculty, public Student {
  26. public:
  27. TA(int x):Student(x), Faculty(x) {
  28. cout<<"TA::TA(int ) called"<< endl;
  29. }
  30. };
  31.  
  32. int main() {
  33. TA ta1(30);
  34. }
  35. }
Compilation error #stdin compilation error #stdout 0s 3340KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘TA::TA(int)’:
prog.cpp:27:36: warning: base ‘Student’ will be initialized after [-Wreorder]
     TA(int x):Student(x), Faculty(x)   {
                                    ^
prog.cpp:27:36: warning:   base ‘Faculty’ [-Wreorder]
prog.cpp:27:5: warning:   when initialized here [-Wreorder]
     TA(int x):Student(x), Faculty(x)   {
     ^
prog.cpp: At global scope:
prog.cpp:35:1: error: expected declaration before ‘}’ token
 }
 ^
stdout
Standard output is empty