fork download
  1. int printf(const char*, ...);
  2.  
  3. struct A
  4. {
  5. void foo(int p) { a=p; }
  6. int a;
  7. };
  8.  
  9. int main()
  10. {
  11. A r;
  12. const_cast<A>(r).foo(101);
  13. printf("%d", r.a);
  14. }
  15.  
  16.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12: error: invalid use of const_cast with type ‘A’, which is not a pointer, reference, nor a pointer-to-data-member type
stdout
Standard output is empty