fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7. int x;
  8. A() : x(0) {}
  9. void print() { cout << x << endl; }
  10. };
  11.  
  12. class B : private A
  13. {
  14. public:
  15. void access() { x = 10; }
  16. void printA() { A::print(); }
  17. };
  18.  
  19. int main()
  20. {
  21. B b;
  22. b.access();
  23. b.printA();
  24. return 0;
  25. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
10