User Tools

Site Tools


cplusplus:pointers_2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
cplusplus:pointers_2 [2016/03/05 22:24] – [Calling functions by reference] mithatcplusplus:pointers_2 [2016/03/05 22:35] – [Constant pointer to constant data] mithat
Line 89: Line 89:
 void cubeByReference(int *nPtr) void cubeByReference(int *nPtr)
 { {
-    *nPtr = *nPtr * *nPtr * *nPtr;+    *nPtr = (*nPtr(*nPtr(*nPtr)// parenthesis for readability
 } }
 </file> </file>
Line 162: Line 162:
 </code> </code>
  
- +One way to remember this is "const modifies the thing immediately following it." In the case of <code c++>int *const myPtr = &x;</code> ''const'' modifies ''myPtr'', meaning the value of ''myPtr'' is constant. In the case of <code c++>const int *myPtr = &x;</code> ''const'' modifies ''int'', meaning the value of the ''int'' is constant.
- +
cplusplus/pointers_2.txt · Last modified: 2019/03/28 16:55 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki