Borland/Delphi替代__super关键字

tru*_*ker 7 c++ delphi compiler-construction c++builder

关键字__super是Microsoft特有的.它用于访问父类的虚方法.您是否知道borland c ++/delphi编译器的替代关键词?

class MyBaseClass
{
    virtual void DoSomething();
};

class MyDerivedClass : public MyBaseClass
{
    virtual void DoSomething();
};

void MyBaseClass::DoSomething()
{
    // some code
}

void MyDerivedClass::DoSomething()
{
    __super::DoSomething();  // calls implementation of base class - no need to know name of base class

    // implementation specific to derived class adding new functionality
}
Run Code Online (Sandbox Code Playgroud)

Dav*_*nan 9

Delphi中的等价物是inherited.据我所知,C++ Builder中没有等效的,当然__super也是非标准的MS扩展.


Ond*_*lle 8

  • 德尔福:inherited MyMethod(MyParam);或缩短inherited;
  • C++ Builder中: MyBaseClass::MyMethod(MyParam);