B
bhavik.patel
Hi
I have a rather simple question:
I have following class definitions:
class Base
{
public:
virtual void display ()
{
cout << "Base";
}
};
class Derivedublic Base
{
public:
virtual void display ()
{
cout << "Derived";
}
};
void main ()
{
Base *ptr = new derived;
ptr->display ();
}
When I compile this code in VC++ 6.0 it works fine.
My question is that can this code work always?
Or the "virtual void display ()" in derived class can create problem?
What can be the problem with this code?
Thanks
I have a rather simple question:
I have following class definitions:
class Base
{
public:
virtual void display ()
{
cout << "Base";
}
};
class Derivedublic Base
{
public:
virtual void display ()
{
cout << "Derived";
}
};
void main ()
{
Base *ptr = new derived;
ptr->display ();
}
When I compile this code in VC++ 6.0 it works fine.
My question is that can this code work always?
Or the "virtual void display ()" in derived class can create problem?
What can be the problem with this code?
Thanks