Does anyone know if virtual functions implicitly call the base class's implementation of said function at all?
For my homework, I have a base class called Package and a child called TwoDayPackage. Package defines a virtual function called calculateCost() which returns a double value in the expression of weight (in ounces) times the cost per ounce. The child class implementation is supposed to add a flat fee on to that. However, as I'm dealing with virtual polymorphism, I'm wondering if there's an alternative to this:
Code:
virtual double calculateCost()
{
return (Package::calculateCost()+flatFee);
}
The above is what TwoDayPackage defines. I don't know if this seems the right way to do this though. My assignment is to modify my previous homework assignment by virtual-izing the functions, but despite being virtual, TwoDayPackage seems to disregard Package's implementation if I take out the call to the base function call and just give me the flat fee only, as I've seen in the test program I made to debug it.