1
我有关于如何通过继承访问具有相同名称的成员的问题。例如,如何在继承中访问具有相同名称的成员
class Base {
public:
int i;
};
class Derived1 : public Base {
public:
int i;
// how to access the i in the base class here?
};
int main() {
Derived1 d;
cout<<d.i; //which is it is?
//how to access the different i here?
}
+1用于回答问题,并指出这通常不是一个好主意。 – 2010-03-08 16:51:50