SHARE
TWEET

Untitled

a guest Jun 19th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void foo(const int*x, int*y)
  2. {
  3.   cout << *x << *y << '\n'; // 0 0
  4.   *y = 2;
  5.   cout << *x << *y << '\n;  // 2 2
  6.   *const_cast<int*>(x) = 3
  7.   cout << *x << *y << '\n'  // 4 4
  8. }
  9.  
  10. struct S {
  11.   int x;
  12.   int *y;
  13. };
  14.  
  15. const S cs;
  16. cs.x = 0; // ошибка
  17. cs->y = 1; // ok
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top