fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. void printA() {std::cout << "A " << this << std::endl;}
  6. };
  7.  
  8. class B
  9. {
  10. void printB() {std::cout << "B " << this << std::endl;}
  11. };
  12.  
  13. class C : public A, public B
  14. {
  15.  
  16. };
  17.  
  18. using namespace std;
  19.  
  20. int main() {
  21. // your code goes here
  22.  
  23. C* c = new C();
  24. A* a = c;
  25. B* b = c;
  26. a->printA();
  27. b->printB();
  28.  
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:5:7: error: 'void A::printA()' is private
  void printA() {std::cout << "A " << this << std::endl;}
       ^
prog.cpp:26:12: error: within this context
  a->printA();
            ^
prog.cpp:10:7: error: 'void B::printB()' is private
  void printB() {std::cout << "B " << this << std::endl;}
       ^
prog.cpp:27:12: error: within this context
  b->printB();
            ^
stdout
Standard output is empty