fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Test {
  5. const int a;
  6. int& b;
  7. };
  8.  
  9. int main() {
  10. Test test;
  11. return 0;
  12. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:15: warning: non-static const member ‘const int Test::a’ in class without a constructor [-Wuninitialized]
     const int a;
               ^
prog.cpp:6:10: warning: non-static reference ‘int& Test::b’ in class without a constructor [-Wuninitialized]
     int& b;        
          ^
prog.cpp: In function ‘int main()’:
prog.cpp:10:7: error: uninitialized const member in ‘class Test’
  Test test;
       ^
prog.cpp:5:15: note: ‘Test::a’ should be initialized
     const int a;
               ^
prog.cpp:10:7: error: uninitialized reference member in ‘class Test’
  Test test;
       ^
prog.cpp:6:10: note: ‘Test::b’ should be initialized
     int& b;        
          ^
prog.cpp:10:7: warning: unused variable ‘test’ [-Wunused-variable]
  Test test;
       ^
stdout
Standard output is empty