在MSDN中, __super解釋為:允許您顯式說明要為正在重寫的函數調用基類實作,看上去很難了解,是以自己歸納了如下:
1.在包含多個基類時, 使用__super可以自動找到正确的基類.
2.如果兩個基類成員名稱相同,編譯器會報錯.
3.__super 不能和 using一起使用.
示例:
struct B1 {
void mf(int) {}
};
struct B2 {
void mf(short) {}
void mf(char) {}
};
struct D : B1, B2 {
void mf(short) {
__super::mf(1); // Calls B1::mf(int)
__super::mf('s'); // Calls B2::mf(char)
}
};