I'm a newb to C++ and like most newbs I'm struggling with the use of pointers a bit. Can someone check that I have the following code interpreted correctly?
CPeerGroup *g_cPeerGroup = NULL;
1. This line creates a pointer to a CPeerGroup object?
g_cPeerGroup = new CPeerGroup[g_iMaxNumGroups[PEERGROUP]];
2. This line allocates memory for an array of CPeerGroup objects and returns the pointer to the first element?
This is the part that's the crux of my confusion...
for (iCounter = 0; iCounter < g_iCurrentNumGroups[PEERGROUP]; ++iCounter)//DP 11/29 Changed to currentNumGroups
3. g_cPeerGroup[X] is the address of the Xth CPeerGroup object?
4. You can call a member function of the CPeerGroup class with (address).ClearMemberList() without having to dereference the address (i.e. *g_cPeerGroup[iCounter].ClearMemberList())?
Can someone answer the four questions above? Thanks!