我得到的错误obj.a::get();
是a类无法访问,我知道这obj.get()
会标记一个错误,但我想这应该可以,这里有什么问题?
class a {
int arg1;
public:
a(int i){
arg1 = i;
cout << "a() called" << endl;
}
void get() {
cout << "arg1=" << arg1 << endl;
}
};
class b {
int arg2;
public:
b(int j) {
arg2 = j;
cout << "b() called" << endl;
}
void get() {
cout << "arg2=" << arg2 << endl;
}
};
class c: private a, private b {
int arg3;
public:
c(int i, int j, int k): b(k), a(j) {
arg3 = k;
cout << "c() called" << endl;
}
};
int main() {
c obj(1, 2, 3);
obj.a::get();
}