fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base { public: static int staticVar; };
  5. Base::staticVar = 0;
  6.  
  7. class DerivedA : public Base {};
  8. class DerivedB : public Base {};
  9.  
  10. int main()
  11. {
  12. DerivedA::staticVar = 1;
  13. DerivedB::staticVar = 2;
  14.  
  15. cout << DerivedA::staticVar << ' ' << DerivedB::staticVar << endl;
  16.  
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:7: error: 'staticVar' in 'class Base' does not name a type
 Base::staticVar = 0;
       ^
stdout
Standard output is empty