October 2011
Beginner to intermediate
1200 pages
35h 33m
English
override and finalVirtual methods are an important component of implementing polymorphic class hierarchies, in which a base class reference or pointer can invoke the particular method appropriate to the type of object referred to. Virtual methods do pose some programming pitfalls. For instance, suppose the base class declares a particular virtual method, and you decide to provide a different version for a derived class. This is called overriding the old version. But, as discussed in Chapter 13, “Class Inheritance,” if you mismatch the function signature, you hide rather than override the old version:
class Action{ int a;public: Action(int i = 0) : a(i) {} int val() const {return a;}; virtual void f(char ...
Read now
Unlock full access