OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Nonvirtual functions

You should not override nonvirtual functions.

Therefore, it's important to make virtual any member function that derived classes might need to override (an exception is the event-handling functions defined in your response tables). For example, TWindow::CanClose is virtual because derived classes should override it to verify whether the window should close. On the other hand, TWindow::SetCaption is nonvirtual because you usually don't need to change the way a window's caption is set.

The problem with using overriding nonvirtual functions is that classes that are derived from your derived class might try to use the overridden function. Unless the new derived classes are explicitly aware that you changed the functionality of the derived function, this can lead to faulty return values and run-time errors.