I understand that poly morphism is just where the parent class is the interface and the behavior is defined by the derived class. So the proper way to do it is:
animal *a1 = new dog();
a1->speak();
And I understand that the following example is the wrong way to do it because of “slicing” and it will just call the animal speak:
animal a1 = dog();
a1->speak();
I’m just curious what is “slicing” and why does it do what it does? Aka what goes on in the background?