What does *pointer_to_class means?

hajimeml's Avatar, Join Date: Jul 2009
Newbie Member
Hello. I am trying to understand a program. In class CGG, there is a definition:

CPGE *PGE;

I guess it means that PGE is a pointer to class CPGE. Inside the class CPGE, there is a member function called RSFPtr(). Inside class CGG, there is a statement:

(*PGE->RSFPtr())[i] = TempRFState[i];

As far as I understand, PGE->RSFPtr() means calling the member function RSFPtr(). The above statment is different. Could you please let me know what it means?
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
When I saw your question, what immediate came to my mind is that .. the function RSFptr() must be returning pointer to an array and so the statement (*PGE->RSFPtr())[i] = TempRFState[i]; assigns TempRFState[i] to the i'th element of that array.

Try to run the following test code for further clarification :
Code: C
#include <stdio.h>

#define SIZE 1000
class Test
{
    private:
        int Array[SIZE];

    public:
        int* AccessArray()    {   return Array;   }
};

int main()
{
    Test ClassA;
    Test* pClassA = &ClassA;

    for(int i = 0; i < SIZE; ++i)
        (pClassA->AccessArray())[i] = i;

    for(int i = 0; i < SIZE; ++i)
        printf("%u\n", (pClassA->AccessArray())[i]);

    return 0;
}

There might be some other meaning of (*PGE->RSFPtr())[i] = TempRFState[i];
If I find any other meaning, I'll update this thread
0
hajimeml's Avatar, Join Date: Jul 2009
Newbie Member
Thanks for the help. Do you mean the * dereference operator in front of PGE returns to the address of the first element of the array and the [i] moves the pointer to the ith element of the array? When i=0, *PGE just points to the first element of the array?
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
>> Do you mean the * dereference operator in front of PGE returns to the address of the first element of the array and the [i] moves the pointer to the ith element of the array? When i=0, *PGE just points to the first element of the array?

Yes, that's what I meant !

>> Thanks for the help
My pleasure !
0
hajimeml's Avatar, Join Date: Jul 2009
Newbie Member
Thanks again.