virtual function
Posted
by hitech
on Stack Overflow
See other posts from Stack Overflow
or by hitech
Published on 2010-03-18T00:49:53Z
Indexed on
2010/03/18
1:01 UTC
Read the original article
Hit count: 308
c++
class a
{
virtual void foo(void) ;
};
class b : public a
{
public:
virtual void foo(void)
{
cout<< "class b";
}
};
int main ( )
{
class a *b_ptr = new b ;
b_ptr->foo();
}
please guide me why the b_ptr->foo() will not call the foo() function of the class b?
© Stack Overflow or respective owner