S
sri
class Base
{
public:
virtual void f(int) { std::cout<<"base.f(int)\n";};
virtual void f(std::complex<double>) { std::cout<<"derived.f
\n"; };
};
class Derived : public Base
{
public :
virtual void f(double) {std::cout<<"base.f(double)\n";};
};
int main()
{
Base b; //Line 1
Derived d; //Line 2
Base* pb = new Derived; //Line 3
pb->f(1.0f); //Line 4
return 0;
}
the above program is calling f(int) version, why the overloading
resolution is calling f(int) version in Base class?
with Regards,
Sri
{
public:
virtual void f(int) { std::cout<<"base.f(int)\n";};
virtual void f(std::complex<double>) { std::cout<<"derived.f
\n"; };
};
class Derived : public Base
{
public :
virtual void f(double) {std::cout<<"base.f(double)\n";};
};
int main()
{
Base b; //Line 1
Derived d; //Line 2
Base* pb = new Derived; //Line 3
pb->f(1.0f); //Line 4
return 0;
}
the above program is calling f(int) version, why the overloading
resolution is calling f(int) version in Base class?
with Regards,
Sri