#Subclass object into function that takes superclass object
1 messages · Page 1 of 1 (latest)
Yes, but it will 'slice' the chocolate_cake object into just a cake, and call the cake's methods instead. You need to pass a reference to that chocolate_cake to use polymorphism, I believe
correct
derived classes are almost always bigger than their base classes. So if you have a "box" the size of the base class, then trying to put a derived class into that box "slices off" the extra information from the derived class
so you use references/pointers to get around this