V
vabby
Hi
I have run into an eerie situation whihc i cant make out. I have a
class A which has has two virtual functions with the same name, having
diff arguments. Basically a case of function overloading.
Also there is a class B, which is derived form A and has one of the
functions in the base class overridden.
So this is the scenario.
Class A
{
public:
int virtual test(int a, int b)
{
cout<<"inside A::test(int,int)";
return a+b;
}
float virtual test(float a, float b)
{
cout<<"inside A::test(float,float)";
return a+b;
}
}
Class B : public A
{
public:
int test(int a, int b)
{
cout<<"inside B::test(int,int)";
return a + b;
}
}
Now i have the following code in the main function
B* obj = new B();
obj->test(2,3); //this wrks fine
obj->test(2.3,2.5); //this is giving me compilation error.
// I dont known why ???
the second call fails during compilation. Ideally it should make a call
to A::test(float, float)
Plz let me know if i m doing anything wrong
Tx
Vaibhav
I have run into an eerie situation whihc i cant make out. I have a
class A which has has two virtual functions with the same name, having
diff arguments. Basically a case of function overloading.
Also there is a class B, which is derived form A and has one of the
functions in the base class overridden.
So this is the scenario.
Class A
{
public:
int virtual test(int a, int b)
{
cout<<"inside A::test(int,int)";
return a+b;
}
float virtual test(float a, float b)
{
cout<<"inside A::test(float,float)";
return a+b;
}
}
Class B : public A
{
public:
int test(int a, int b)
{
cout<<"inside B::test(int,int)";
return a + b;
}
}
Now i have the following code in the main function
B* obj = new B();
obj->test(2,3); //this wrks fine
obj->test(2.3,2.5); //this is giving me compilation error.
// I dont known why ???
the second call fails during compilation. Ideally it should make a call
to A::test(float, float)
Plz let me know if i m doing anything wrong
Tx
Vaibhav