C++的super關鍵字

工做中看到別人的代碼有__super::SetWindowSize()這樣的代碼,查詢了一下備忘在這裏。
Visual Studio 2005中新增了__super關鍵字,它表明本類的基類,所以能夠像下面這樣使用:
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)
	}
};
它還能夠配合using語句使用,好比using __super::type_define;這樣的。
相關文章
相關標籤/搜索