In this simple class hierarchy I'm trying to get class C to disambiguate which x to use by telling it "using B::x" but this doesn't compile in G++ because it still can't figure out which x I mean in the function foo. I know using can be used to promote hidden methods but why not variables? I've considered making a class X as a virtual base of A and B with a definition for X but that's not strictly what I want; what I want is A:x used by stuff directly derived from it except when derived from B also, sort of like the way Python does it with its member (name) resolution order algorithm (last class wins, so in this case B:x is used, see http://starship.python.net/crew/timehorse/BFS_vs_MRO.html for a description.)
Am I correct in the assessment that ISO C++ 2011 is deficient in this respect; that it's impossible to disambiguate base member variables using "using"?
class A {
protected:
int x;
};
class B {
protected:
int x;
};
class C : public A, public B {
protected:
using B::x;
public:
int foo(void) { return x; }
};
EDIT: Compiler version: g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3