Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main()
- {
- const int ANSWER = 42;
- int i = 0;
- //ANSWER = 43; // Can't assign to constant
- const int *cp;
- cp = &ANSWER;
- //*cp = 43; // cp points to a (const int)
- cp = &i; // cp's contract allows to modify its contents
- i = 1;
- //*cp = 2; // cp's contract is not to modify the referenced value
- // Assignint to const, the evil way:
- int *p;
- p = &ANSWER; // Warning only (error in C++)
- *p = 43;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement