看看下面的代码
这是错误的
class A {
public:
int x = 10;
};
class B :public A {
using A::x;
int x = 100;
};
看看函数
class A {
public:
void fun()
{
cout << "uuuu" << endl;
}
};
class B :public A {
public:
using A::fun;
void fun()
{
cout << "lalala" << endl;
}
};
int main()
{
B b;
b.fun(); // 输出 lalala
b.A::fun(); // 输出 uuuu
}