Programmeren in C++/Pointers: verschil tussen versies

Verwijderde inhoud Toegevoegde inhoud
Nijdam (overleg | bijdragen)
Geen bewerkingssamenvatting
DimiC88 (overleg | bijdragen)
kGeen bewerkingssamenvatting
 
Regel 7:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
int *intPnt
</syntaxhighlight>
</source>
}}
 
Regel 24:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
#include <iostream>
using namespace std;
Regel 37:
return 0;
}
</syntaxhighlight>
</source>
}}
 
Regel 45:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
shortVar: 5 Adres van shortVar: 0x8fc9:fff4
</syntaxhighlight>
</source>
}}
In dit geval heeft de variabele 'shortVar' het adres '0x8fc9:fff4'. Dat betekent niets anders dan dat de geheugenplaats '0x8fc9:fff4' samen met de drie daarop volgende geheugenplaatsen de variabele 'shortVar' voorstelt. Het adres'0x8fc9:fff4' zelf kan met de naam 'shortVar' aangesproken kan worden. Dat is voor ons gemakkelijker dan steeds dat hex-getal te moeten gebruiken.
Regel 58:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
int myAge = 15; // Maakt variabele myAge
int *pAge = 0; // Maakt pointer pAge
 
pAge = &myAge ; // zet het adres van myAge in de pointer pAge
</syntaxhighlight>
</source>
}}
 
Regel 77:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
int mijnLeeftijd = 18;
int *pLeeftijd = new int;
Regel 84:
cout << *pLeeftijd;
 
</syntaxhighlight>
</source>
}}
 
Regel 104:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
#include <iostream>
using namespace std;
Regel 145:
return 0;
}
</syntaxhighlight>
</source>
}}
 
Regel 159:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
CSimpleCat * pFrisky = new CSimpleCat;
</syntaxhighlight>
</source>
}}
 
Regel 175:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
(*pFrisky).getAge();
</syntaxhighlight>
</source>
}}
 
Regel 185:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
pFrisky->getAge();
</syntaxhighlight>
</source>
}}
 
Regel 195:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
delete pFrisky;
pFrisky = 0;
</syntaxhighlight>
</source>
}}
 
Regel 208:
| Titel=
| Code=
<sourcesyntaxhighlight lang="cpp">
int *pInt = new int;
delete pInt;
pInt = 0;
delete pInt;
</syntaxhighlight>
</source>
}}
 
Informatie afkomstig van https://nl.wikibooks.org Wikibooks NL.
Wikibooks NL is onderdeel van de wikimediafoundation.