For example in below program I undo name hiding by "using" keyword. If I have base and one derived class "im getting expected ambiguous call error". But if I have two derived class(child and grand child) now child and grand child having same overloaded function here also I undo name hiding by "using" keyword. But It is getting compiled and got output. My question is why im not getting error as "ambiguous call to overloaded function".
class baseNameHiding
{
protected:
int nameHidingexample(int t)
{
cout<<"im baseeeeeeeeeeee"<<endl;
return 0;
}
};
class derivedNameHiding:public baseNameHiding
{
public:
float nameHidingexample(float s)
{
cout<<"im derived"<<endl;
return 0;
}
using baseNameHiding::nameHidingexample;
};
class grandDerivedNameHiding:public derivedNameHiding
{
public:
float nameHidingexample(float f)
{
cout<<"im grand derived"<<endl;
return 0;
}
using baseNameHiding::nameHidingexample;
using derivedNameHiding::nameHidingexample;
};
int main()
{
char a;float f = 0.0;
derivedNameHiding derived;
derived.nameHidingexample(0);
grandDerivedNameHiding grandchild;
grandchild.nameHidingexample(f);
cin>>a;
}
//output
im baseeeeeeeeeeee
im grand derived