#include <iostream> using namespace std; class Test { const int a; int& b; }; int main() { Test test; return 0; }
Standard input is empty
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; ^
Standard output is empty