c++ - Borland/Delphi 替代 __super 关键字

标签 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
}

最佳答案

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

关于c++ - Borland/Delphi 替代 __super 关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8326309/

相关文章:

Delphi 2009 - 接口(interface)属性会导致内存泄漏吗?

c++ - 一切都不稳定

Java编译器代码优化违反if条件?

c - netcat gcc 编译选项,以便 IDA pro 可以显示函数名称

c++ - 为什么不同cpp文件中的类的重复定义可以无错误地链接?

c++ - 为什么imread加载图片后像素值为0?

c++ - 双端队列 : is this a sound "add to front" implementation?

c++ - 如何使用成员函数从 main() 访问数组?

delphi - 优化 Delphi 中的类大小。有类似 "packed classes"的东西吗?

json - Delphi XE7 : How to change a JSON value using System. JSON(与 SuperObject)