fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct C
  5. {
  6. void f() { cout << "f" << endl; }
  7. void f() const { cout << "const f" << endl; }
  8. };
  9.  
  10. int main()
  11. {
  12. C c;
  13. c.f();
  14. auto const& const_c = c;
  15. const_c.f();
  16. static_cast<const C*>(&c)->f();
  17. return 0;
  18. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
f
const f
const f