August 2012
Intermediate to advanced
976 pages
30h 17m
English
In some cases, we want to prevent dynamic binding of a call to a virtual function; we want to force the call to use a particular version of that virtual. We can use the scope operator to do so. For example, this code:
// calls the version from the base class regardless of the dynamic type of basePdouble undiscounted = baseP->Quote::net_price(42);
calls the Quote version of net_price regardless of the type of the object to which baseP actually points. This call will be resolved at compile time.
Note
Ordinarily, only code inside member functions (or friends) should need to use the scope operator to circumvent ...
Read now
Unlock full access