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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.