__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() { }这样子成员函数能够调用父的成员函数
时间: 2024-09-29 15:56:52