i have a question about virtual functions or methods. I found a really nice post here on stackoverflow link to post explaining why and how virtual functions work. I understand how virtual functions work now, but i still dont understand WHY u need them. If you look at the link and the provided example, he creates an instance like this:
A *a1 = new B;
a1->show();
But why would u ever want to create an instance like this if you want to use functions from B? Why not do it like this:
B b1 = new B;
b1->show();
why should i use the A pointer when i want to use a B reference?
I hope you guys understand what i dont get about this and can explain it to me.