difference in using virtual and not using virtual
- by numerical25
In C++, whether you choose to use virtual or not, you can still override the base class function. The following compiles just fine...
class Enemy
{
public:
void SelectAnimation();
void RunAI();
void Interact()
{
cout<<"Hi I am a regular Enemy";
}
private:
int m_iHitPoints;
};
class Boss : public Enemy
{
public:
void Interact()
{
cout<<"Hi I am a evil Boss";
}
};
So my question is what is the difference in using or not using the virtual function. And what is the disadvantage.