Virtual Member Functions

virtual should always be used on a function in the protected section. If you envision a public function being overridden, it should also get the virtual keyword.

Some programmers worry about the performance penalty of the indirect virtual function call. In truth, this is probably not a significant drag on typical program performance, compared to things such as file I/O or database access, or even the time it takes to type a character.

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.