vc++ -- __super

vc++中,用於顯示調用 所重寫的函數 對應的 基類的函數;有多個基類或多個基類的重寫函數時,會調用最匹配的那個函數;

語法: __super::member_function(); 

只可以出現在成員函數的作用域內;

example:

// deriv_super.cpp
// compile with: /c
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)
   }
};

 

發佈了72 篇原創文章 · 獲贊 10 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章