I was shocked today by the fact that this code snippet has an ambiguous name reference:
class A
{
private:
typedef int Type;
};
class B
{
public:
typedef int Type;
};
class D : A, B
{
Type value;//error: reference to 'Type' is ambiguous
};
Hmm! Imagine you are the author of class A
and your class has already been used everywhere by different people and different projects. One day you decide to rewrite your A
class. Doesn't this mean that you cannot use any new (even private) name in your new class without breaking others' code?
What is the convention here?
public/private
declarations. But the legality of them is. If it compiled the first time, changingprivate
topublic
should not break it.