inheritance question

i have this code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Top
{
public:
	void f (int i) {cout<<endl<<i;};
	void f (double d) {cout<<endl<<d;};
};
class Left :public virtual Top
{
};
class Right :public virtual Top
{
public:
	void f(int i)
	{cout<<"Right::f"<<endl;};
};

class Bottom :public Left,public Right
{
};

void main (void)
{
	Bottom b;
	b.f(123.123);
	//b.Top::f(123.123);
	cout<<"\npress<ENTER> to terminate";
	cout.flush();
	getchar();
}


the programm prints Right::f

why doesnt it print 123.23??
why doesnt it choose the f with double parameter???
Name Hiding

Top::f(double) function is hidden from class Bottom, because class Right also have a function called f and it is directly in the inheritance chain


Last edited on
ok thank you my friend!!
Topic archived. No new replies allowed.