-
Posts
1443 -
Joined
Sarah's Achievements
Single Status Update
-
The . operator is used when accessing a structure or class that is not a pointer. For example:
CPlayer cNewPlayer;
//some stuff
int iPID = cNewPlayer.getPlayerID();
printf("Player ID: %d\n", iPID);
The . operator calls the member function getPlayerID. Since the declaration wasn't a pointer, it doesn't use the -> operator. An example of using the -> would be:
CPlayerAmmo *cptrPAmmo;
//Some stuff
if ( cptrPAmmo->getHandgunAmmo() <= 0) {
cNewPlayer.setEmptyClip(mHandGun, true);
return 0;
}
Hope that helps.