Item 63. Optional Keywords

Some keyword usage is strictly optional from the perspective of the C++ language, though other considerations may argue for their presence or absence.

The most common source of confusion is the optional use of virtual in a derived class member function that overrides a base class virtual member function.

image

The member function Blob::draw overrides the base class draw function and so is virtual; the use of the keyword is completely optional and has no effect on the meaning of the program. A common misassumption is that omitting the virtual keyword will prevent further overriding in more derived classes. This is not the ...

Get C++ Common Knowledge: Essential Intermediate Programming 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.