fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. class Account
  5. {
  6. public:
  7. Account() {}
  8. unsigned long A1;
  9. };
  10.  
  11. class Employee : public Account
  12. {
  13. public:
  14. Employee() {}
  15. unsigned long E1;
  16. };
  17.  
  18. class Student : public Account
  19. {
  20. public:
  21. Student() {}
  22. unsigned long S1;
  23. };
  24.  
  25. class Work_Study : public Employee, public Student
  26. {
  27. public:
  28. Work_Study() {}
  29. unsigned long W1;
  30. };
  31.  
  32. Work_Study Obj_WS; // declare a Work_Study object;
  33. Work_Study *Obj_WS_ptr = &Obj_WS;
  34.  
  35. int main()
  36. {
  37. std::cout << "Employee Account " << &(Obj_WS_ptr->Employee::A1) << std::endl;
  38. std::cout << "Employee " << &(Obj_WS_ptr->E1) << std::endl;
  39. std::cout << "Student Account " << &(Obj_WS_ptr->Student::A1) << std::endl;
  40. std::cout << "Student " << &(Obj_WS_ptr->S1) << std::endl;
  41. std::cout << "Work_Study " << &(Obj_WS_ptr->W1) << std::endl;
  42. return 0;
  43. }
Success #stdin #stdout 0s 4176KB
stdin
Standard input is empty
stdout
Employee Account 0x558191471140
Employee 0x558191471148
Student Account 0x558191471150
Student 0x558191471158
Work_Study 0x558191471160