fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class A {
  6. protected:
  7. int val;
  8. public:
  9. A(int x) : val(x) {}
  10. };
  11.  
  12. struct B : public A {
  13. B(int x) : A(x) {}
  14. };
  15.  
  16. struct C : public B {
  17. C(int x) : B(x) {}
  18. void show() {
  19. cout << val << endl;
  20. }
  21. };
  22.  
  23. int main() {
  24. C c(123);
  25. c.show();
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
123