-
-
Save miyuki/606ebc09104cef675e03767b322508a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void foo(const int*x, int*y) | |
{ | |
cout << *x << *y << '\n'; // 0 0 | |
*y = 2; | |
cout << *x << *y << '\n; // 2 2 | |
*const_cast<int*>(x) = 3 | |
cout << *x << *y << '\n' // 4 4 | |
} | |
struct S { | |
int x; | |
int *y; | |
}; | |
const S cs; | |
cs.x = 0; // ошибка | |
cs->y = 1; // ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment