1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

What does *pointer_to_class means?

Discussion in 'C' started by hajimeml, Jul 3, 2009.

  1. hajimeml

    hajimeml New Member

    Joined:
    Jul 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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()) = TempRFState;

    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?
     
  2. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    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()) = TempRFState; assigns TempRFState to the i'th element of that array.

    Try to run the following test code for further clarification :
    Code:
    #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()) = TempRFState;
    If I find any other meaning, I'll update this thread :)
     
  3. hajimeml

    hajimeml New Member

    Joined:
    Jul 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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 moves the pointer to the ith element of the array? When i=0, *PGE just points to the first element of the array?
     
  4. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    >> Do you mean the * dereference operator in front of PGE returns to the address of the first element of the array and the 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 !
     
  5. hajimeml

    hajimeml New Member

    Joined:
    Jul 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Thanks again.
     

Share This Page