fork(5) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class c1
  5. {
  6. public:
  7. class c2
  8. {
  9. protected:
  10. static void func();
  11. };
  12.  
  13. public:
  14. static int a1;
  15. private:
  16. static int a2;
  17. };
  18.  
  19.  
  20.  
  21. void c1::c2::func()
  22. {
  23. int f1= c1::a1; //works
  24. int f2= c1::a2;
  25.  
  26. c1::a1= 1; //fails
  27. c1::a2= 2;
  28.  
  29. printf("func");
  30. }
  31.  
  32. int main() {
  33. // your code goes here
  34. return 0;
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In static member function ‘static void c1::c2::func()’:
prog.cpp:23:9: warning: unused variable ‘f1’ [-Wunused-variable]
     int f1= c1::a1; //works
         ^
prog.cpp:24:9: warning: unused variable ‘f2’ [-Wunused-variable]
     int f2= c1::a2;
         ^
/home/d91WcC/cc5NqOCF.o: In function `c1::c2::func()':
prog.cpp:(.text+0xc): undefined reference to `c1::a1'
prog.cpp:(.text+0x16): undefined reference to `c1::a2'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty