User Tools

Site Tools


cplusplus:pointers_1_slides

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_1_slides [2019/03/28 16:19] mithatcplusplus:pointers_1_slides [2021/10/19 19:13] – [Pointer hardware model] mithat
Line 2: Line 2:
 ~~NOTOC~~ ~~NOTOC~~
  
-====== Pointers 1 ======+====== Pointers 1 slides ======
 Pointer fundamentals, syntax, and operations.((Portions loosely adapted from: Pointer fundamentals, syntax, and operations.((Portions loosely adapted from:
 Deitel, Harvey M., and Paul J. Deitel. "Pointers and Strings." In //C++: How to Program//. 3 ed. Upper Saddle River, NJ: Prentice Hall, 2001. 304-388.))\\  Deitel, Harvey M., and Paul J. Deitel. "Pointers and Strings." In //C++: How to Program//. 3 ed. Upper Saddle River, NJ: Prentice Hall, 2001. 304-388.))\\ 
Line 23: Line 23:
  
 ===== Pointer hardware model ===== ===== Pointer hardware model =====
-Assume an ''int'' named ''count'' storing the value 7 and ''int''s occupy 4 bytes.+  * Assume an ''int'' named ''count'' storing the value 7 and ''int''s occupy 4 bytes.
  
 ^ 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:
 |:::|58003|:::| |:::|58003|:::|
  
-The address of ''count'' is the base address 58000.  +  * The address of ''count'' is the base address 58000. 
  
 ===== Pointer hardware model ===== ===== Pointer hardware model =====
Line 42: Line 42:
 |:::|64009|:::| |:::|64009|:::|
  
-The //value// of the pointer variable is the base address it stores.+The //value// of the pointer variable is the base address of another variable.
  
 ===== Pointer visual model ===== ===== Pointer visual model =====
Line 171: Line 171:
 ===== Indirection/dereferencing operator ===== ===== Indirection/dereferencing operator =====
  
-  * **indirection** or **dereferencing** operator, ''*'', returns the value of what its operand points to.+  * **indirection** or **dereferencing** operator, ''*'', accesses the value of what its operand points to.
  
 <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</code> cout << y;        // prints 7</code>
- 
-===== Indirection/dereferencing operator ===== 
  
   * You can think of the indirection/dereferencing operator as meaning, “the_thing_at_the_end_of_”, as in:   * You can think of the indirection/dereferencing operator as meaning, “the_thing_at_the_end_of_”, as in:
cplusplus/pointers_1_slides.txt · Last modified: 2021/10/19 19:29 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki