cplusplus:pointers_4_slides
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
cplusplus:pointers_4_slides [2019/03/31 22:36] – mithat | cplusplus:pointers_4_slides [2021/10/24 02:56] – [Memory management of regular variables] mithat | ||
---|---|---|---|
Line 17: | Line 17: | ||
* reserves a block of memory to hold the specified %%< | * reserves a block of memory to hold the specified %%< | ||
* returns the base address of that block. | * returns the base address of that block. | ||
+ | * optional parenthesis around ''< | ||
<code cpp> | <code cpp> | ||
Line 25: | Line 26: | ||
</ | </ | ||
- | * '' | + | * '' |
===== Example ===== | ===== Example ===== | ||
Line 108: | Line 109: | ||
void ninetynine() | void ninetynine() | ||
{ | { | ||
- | int localVar = 99; | + | int localVar = 99; // localVar is destroyed at end of fcn call |
cout << localVar << endl; | cout << localVar << endl; | ||
} | } | ||
Line 138: | Line 139: | ||
void ninetynine() | void ninetynine() | ||
{ | { | ||
- | int *localPtr = new int; | + | int *localPtr = nullptr; |
+ | | ||
*localPtr = 99; | *localPtr = 99; |
cplusplus/pointers_4_slides.txt · Last modified: 2021/10/24 03:02 by mithat