User Tools

Site Tools


cplusplus:pointers_3

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
Last revisionBoth sides next revision
cplusplus:pointers_3 [2015/12/31 20:51] mithatcplusplus:pointers_3 [2016/03/05 23:27] – [Pointers 3] mithat
Line 2: Line 2:
  
 Pointers, arrays, arithmetic.((Portions loosely adapted from: FIXME)) Pointers, arrays, arithmetic.((Portions loosely adapted from: FIXME))
- 
-<WRAP center round important 60%> 
-This content has not been vetted for C++11 compliance. 
-</WRAP> 
  
 ===== Pointers and arrays ===== ===== Pointers and arrays =====
Line 101: Line 97:
     int *vPtr = v;     int *vPtr = v;
  
-    for(int i = 0; i < 5; i++)+    for (int i = 0; i < 5; i++)
     {     {
         cout << *vPtr << endl;         cout << *vPtr << endl;
Line 154: Line 150:
  
 ^ Operation                                                        ^ Example ^ ^ Operation                                                        ^ Example ^
-|<code>{pointer}++</code>                                          |<code cpp>valptr++;  // points at 7</code>+|Increment <code>pointer++</code>                                          |<code cpp>valptr++;  // points at 7</code>
-|<code>{pointer}--</code>                                          |<code cpp>valptr--;  // now points at 4</code>+|Decrement <code>pointer--</code>                                          |<code cpp>valptr--;  // now points at 4</code>
-|<code>{pointer{int}</code>and<code>{pointer{int}</code>   |<code cpp>cout << *(valptr + 2); // prints 11</code>+|Arithmetic <code>pointer + int</code> and <code>pointer - int</code> |<code cpp>cout << *(valptr + 2); // prints 11</code>
-|<code>{pointer+= {int}</code>and<code>{pointer-= {int}</code> |<code cpp>valptr = vals; // points at 4+|Compound assignment <code>pointer += int</code>and<code>pointer -= int</code> |<code cpp>valptr = vals; // points at 4
 valptr += 2;   // points at 11</code> | valptr += 2;   // points at 11</code> |
-|<code>{pointer{pointer}</code>                                |<code cpp>cout << valptr - val; // number of ints between valptr and val</code> |+|Pointer subtraction <code>pointer - pointer</code>                                |<code cpp>cout << valptr - val; // of ints between valptr and val</code> |
  
cplusplus/pointers_3.txt · Last modified: 2016/03/05 23:27 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki