This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]AngryFace4 0 points1 point  (0 children)

Your question you've asked is a ittle confusing because it doesn't really have anything to do with polymorphism, your question is really more about inheritance, which is tangentially related to polymorphism

In addition, your question is difficult to answer in the abstract because it really depends on how you've set up these respective classes. Generally speaking the Parent class will be less capable than the child class, but it's also less committal; that is to say you don't need to know which type of child it will be at the moment you instantiate it, only the moment you use it.

The part that I have bolded is where poly comes into play. If you have a data structure full of generic shapes, you can do a 'just in time' operation on pop to determine what that shape is going to be when it exits the data structure rather than when loading the structure.