__super
Visual Studio 2005中新增了__super關鍵字,它代表本類的基類。
使用方法
__super::member_function();
實驗得,該關鍵詞會自動尋找最近重載的虛函數調用,即連續重載的各個類,會調用最近的重載基類的虛函數。
__super代表該基類的空間類名
#include <iostream> using namespace std; class base { public: virtual void fun(){ cout << "base" << endl; } }; class A :public base { public: void fun() override{cout << "A" << endl;} }; class B :public A { public: void fun() override { __super::fun(); cout << "B" << endl; } }; void main() { B b; b.fun(); //輸出 A B }