This fails because aa is already in this area. using AAA.aa will return it to the scope again.
you can apply this to a type and extract it that way.
#include <iostream> struct AAA { int aa; AAA() : aa(1) {} virtual ~AAA(){}; }; struct BBB { int aa; BBB() : aa(5) {} virtual ~BBB(){}; }; struct CCC : public AAA , public BBB { CCC() : AAA(), BBB() {} // using AAA::aa; }; int main() { CCC ccc; std::cout << static_cast<BBB*>(&ccc)->aa << std::endl; }
Although, if this is something that you intend to do a lot, it may be easier to just encapsulate this functionality.
//member of CCC int get_aa() { return static_cast<BBB*>(this)->aa; }
source share