11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 21: Examining Virtual Member Functions: Are They for Real? 275in terms of data storage and code needed to perform the call. The founders ofC++ were concerned that any additional overhead would be used as a reasonnot to adopt C++ as the system’s language of choice, so they made the moreefficient early binding the default.One final reason is that it can be useful as a programmer of a given class todecide whether you want a given member function to be overridden at sometime in the future. This argument is strong enough that Microsoft’s new C#language also allows the programmer to flag a function as not overridable(however, the default is overridable).To make a member function polymorphic, the programmer must flag thefunction with the C++ keyword virtual, as shown in the following modificationto the declaration in the OverloadOveride program:class Student{public:virtual float calcTuition(){cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!