Created
September 16, 2015 20:36
-
-
Save peterflynn/7644af3d72b3aba20a96 to your computer and use it in GitHub Desktop.
C++ Pointer Syntax Cheatsheet
This file contains hidden or 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
// If "const" is to the LEFT of "*" it applies to the object being pointed at | |
// If "const" is to the RIGHT of "*" it applies to the variable holding the pointer address | |
const T* ptr; // object is immutable | |
T const* ptr; // " | |
T* const ptr; // 'ptr' cannot be changed to point to a different address, but object is not immutable | |
// (i.e. the variable is const, not the thing it points to) | |
const T* const ptr; // object is immutable AND 'ptr' cannot be changed to point to a different address |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment