Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Borland / Delphi alternative to __super keyword

Keyword __super is Microsoft specific. It is used to access virtual methods of parent class. Do you know alternative keywords for borland c++ / delphi compilers?

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
}
like image 652
truthseeker Avatar asked Nov 30 '11 12:11

truthseeker


3 Answers

The equivalent in Delphi is inherited. So far as I know, there is no equivalent in C++ Builder and of course __super is a non-standard MS extension.

like image 126
David Heffernan Avatar answered Nov 12 '22 03:11

David Heffernan


  • Delphi: inherited MyMethod(MyParam); or shortened inherited;
  • C++Builder: MyBaseClass::MyMethod(MyParam);
like image 29
Ondrej Kelle Avatar answered Nov 12 '22 04:11

Ondrej Kelle


In Delphi, the equivalent is inherited. You can see examples of it in use in the RTL and VCL sources.

like image 23
Mason Wheeler Avatar answered Nov 12 '22 04:11

Mason Wheeler