Hi,

Here is the program you have explained below and it's output too

Code:
#include<iostream.h>

class Base
{
  public:
    virtual bool foo()
    {
      cout<<"Base::foo"<<endl;
    }
};
  
class Derived: public Base
{
  public:
    bool foo()
    {
      cout<<"Derived::foo"<<endl;
    }
};

bool doSomething(Base * foo)
{ 
  foo->foo(); 
}

int main()
{
  Base *bptr = new Derived();
  bptr->foo();
  doSomething(bptr);
  
  return(0);
}
output:

Derived::foo
Derived::foo


You must get the output as you were expecting. I think, you have made some mistake to get the output as

Derived::foo
Base::foo


So, double check your code.

Last edited by shabbir; 2Sep2009 at 18:44.. Reason: Code blocks