In multiple inheritance c++ with same attribute in suber class like this code
class A{
protected :
int var;
}
class B{
protected :
int var;
}
class C: public A,B{
C(){
A::var=3;
B::var=5;
}
}
i must write A::var or B::var to determine the super class
is there any way to redefine the attribute in C class like
#define AA = A::var
Surely you may
#defineeverything. But this is not a good altitude. AlsoAAwould be defined everywhere in your code, not only in the scope ofclass C.You may add:
So that
varwould beA::varby default.Besides of this you may add a member function that would return you a reference to your member variable, if you don’t want to add
A::everywhere.