fork download
  1. struct Bla{
  2. void constFoo() const{}
  3. void nonConstFoo(){}
  4. };
  5.  
  6. int main() {
  7. Bla nonConstBla;
  8. const Bla constBla;
  9. nonConstBla.constFoo(); //kein Problem
  10. constBla.nonConstFoo(); //Error
  11. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:10:23: error: passing ‘const Bla’ as ‘this’ argument of ‘void Bla::nonConstFoo()’ discards qualifiers [-fpermissive]
  constBla.nonConstFoo(); //Error
                       ^
stdout
Standard output is empty