DEV Community

Discussion on: Function Overloading vs Function Overriding in C++

Collapse
 
pauljlucas profile image
Paul J. Lucas

You should really use double and not float. (Floating-point literals like 2.0 are of type double anyway.) The only time you should use float is if you have either a struct containing a float or an array of float and you have a lot of them to the point where you really need to conserve memory.

In DerivedClass, you should really declare Display() like:

void Display() override
Enter fullscreen mode Exit fullscreen mode

then it's obvious to both the compiler and the human reader that the function is overriding one in the base class. See here for more information.