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