fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int i = 5;
  5.  
  6. void cast(const int *j)
  7. {
  8. *const_cast<int *>(j) = 1;
  9. }
  10.  
  11. int main(void)
  12. {
  13. cout << "i = " << i << endl;
  14. cast(&i);
  15. cout << "i = " << i << endl;
  16. }
  17.  
Runtime error #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
i = 5