Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Class B : Class A { void getBasePointer() { this->basePointer; //How can I access Class A ? } }
如何获得指向Class Ain的指针Class B?
Class A
Class B
this强制转换为 就足够了A *,但我认为这没有用(除非你必须提供一个A *to 某个函数,但在这种情况下,强制转换是隐式的);相反,如果重点是您想调用某个方法的基类版本,那么您必须调用A::methodName().
this
A *
A::methodName()