fork download
  1. struct A
  2. {
  3. constexpr int f() { return 0; }
  4. };
  5.  
  6. void f()
  7. {
  8. const A a1;
  9. a1.f(); // Only works in C++11. For C++14 the method has to be declared f() const.
  10. }
  11.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void f()':
prog.cpp:9:7: error: passing 'const A' as 'this' argument discards qualifiers [-fpermissive]
  a1.f(); // Only works in C++11. For C++14 the method has to be declared f() const.
       ^
prog.cpp:3:16: note:   in call to 'constexpr int A::f()'
  constexpr int f() { return 0; }
                ^
stdout
Standard output is empty