CDT
CDT

Reputation: 10671

Qt - How to get the pointer to base class?

Class B : Class A
{
    void getBasePointer() {
        this->basePointer; //How can I access Class A ? 
    }
}

How can I get a pointer to Class A in Class B ?

Upvotes: 0

Views: 265

Answers (1)

Matteo Italia
Matteo Italia

Reputation: 126967

It's enough to cast this to A *, but I see no use in this (unless you have to provide an A * to some function, but in that case the cast is implicit); if, instead, the point is that you want to call the base class version of some method, then you have to call A::methodName().

Upvotes: 2

Related Questions