Reputation: 55
the error i get for obj.a::get();
is class a is inaccessible, i know that obj.get()
would flag an error, but i guess this should work, whats the issue here?
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();
}
Upvotes: 1
Views: 100
Reputation: 126432
c
uses private
to derive from a
, so the a
subobject of c
is inaccessible from functions which are not member functions of c
.
Upvotes: 10