+ 1

Polymorphism

Ok, so I know that polymorphic classes are supposed to have a virtual function. Then it says that abstract classes have a PURE virtual function, consisting of no body. So since pure virtual functions are a type of virtual functions, is it safe to assume that all abstract classes are polymorphic classes but not all polymorphic classes are abstract classes? An analogy would be that every square is a rectangle but not every rectangle is a square.

9th Mar 2017, 3:53 AM
Vin Adikehithilu
1 Réponse
+ 2
yup. or that every dog is an animal but not every animal is a dog. virtual functions are used Only in the child class. kind of like protected variables. but virtual functions Cannot be implemented in the parent class, only initialized. and it should then be declared again with a definition of the child class... hope this helps, if ur post was even a question lol idk
10th Mar 2017, 5:01 AM
Michael Szczepanski
Michael Szczepanski - avatar