Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement