fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class foo
  6. {
  7. public:
  8. foo()
  9. {
  10. test = 2;
  11. }
  12. int get()
  13. {
  14. return test;
  15. }
  16. private:
  17. const int test;
  18. };
  19.  
  20. int main()
  21. {
  22. foo f;
  23. cout<<f.get();
  24.  
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘foo::foo()’:
prog.cpp:8:5: error: uninitialized member ‘foo::test’ with ‘const’ type ‘const int’ [-fpermissive]
prog.cpp:10:16: error: assignment of read-only member ‘foo::test’
stdout
Standard output is empty