cplusplus:pointers_1_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_1_slides [2019/03/28 16:14] – mithat | cplusplus:pointers_1_slides [2021/10/19 19:12] – [Pointer hardware model] mithat | ||
---|---|---|---|
Line 2: | Line 2: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
- | ====== Pointers 1 ====== | + | ====== Pointers 1 slides |
Pointer fundamentals, | Pointer fundamentals, | ||
Deitel, Harvey M., and Paul J. Deitel. " | Deitel, Harvey M., and Paul J. Deitel. " | ||
Line 23: | Line 23: | ||
===== Pointer hardware model ===== | ===== Pointer hardware model ===== | ||
- | Assume an '' | + | * Assume an '' |
^ Variable name ^ Memory location ^ Memory contents across all four bytes (32 bits)^ | ^ Variable name ^ Memory location ^ Memory contents across all four bytes (32 bits)^ | ||
Line 31: | Line 31: | ||
|::: | |::: | ||
- | The address of '' | + | * The address of '' |
===== Pointer hardware model ===== | ===== Pointer hardware model ===== | ||
Line 154: | Line 154: | ||
===== nullptr/ | ===== nullptr/ | ||
- | * You can set a pointer to a value that indicates that it is //pointing to nothing//: '' | + | * You can set a pointer to a value that indicates that it is //pointing to nothing//: '' |
- | * Otherwise uninitialized pointers should be set to '' | + | * Otherwise uninitialized pointers should be set to '' |
<code cpp> | <code cpp> | ||
Line 171: | Line 171: | ||
===== Indirection/ | ===== Indirection/ | ||
- | * **indirection** or **dereferencing** operator, '' | + | * **indirection** or **dereferencing** operator, '' |
<code cpp> | <code cpp> | ||
Line 181: | Line 181: | ||
===== Indirection/ | ===== Indirection/ | ||
- | * Dereferencing can be used to assign a value to a location in memory: | + | |
<code cpp> | <code cpp> | ||
Line 189: | Line 189: | ||
*myPtr = 7; // change value in y to 7 | *myPtr = 7; // change value in y to 7 | ||
cout << y; // prints 7</ | cout << y; // prints 7</ | ||
- | |||
- | ===== Indirection/ | ||
* You can think of the indirection/ | * You can think of the indirection/ |
cplusplus/pointers_1_slides.txt · Last modified: 2021/10/19 19:29 by mithat