line 2 is valid, line 3 is not. animal needs a (pure) virtual display() function.
however you have more problems. Since name is private in animal, dog cannot access it. You need to
make name protected.
you are inheriting animal privately in dog. you should be inheriting it publicly.
Thanks for your replies guys. It really helped me. I'm just trying to create a heterogeneous list and I guess this approach should do it.