您的位置:首页 > 其它

__super

2015-12-30 17:37 253 查看
__super::member_function();

The __super keyword allows you to explicitly state that you are calling a base-class implementation for a function that you are overriding. All accessible base-class methods are considered during the overload resolution phase, and the function that provides the best match is the one that is called.


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)
}
};

int main() {
}

这样子成员函数能够调用父的成员函数


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: