The answer to the below output of main is "derived class display with i=10", but I do not understand why? Surely the function was invoked on the base type?
What is the thought-process in determining the answer here?
class base
{
public:
virtual void display(int i = 10)
{
cout<<"Base class display with i = "<<i<<endl;
}
};
class derived : public base
{
public:
void display(int i = 20)
{
cout<<"Derived class display with i = "<< i <<endl;
}
};
int main(int argc, char *argv[])
{
base *bptr = new derived;
bptr->display();
return 0;
}