< previous page page_193 next page >

Page 193
Hour 13
Advanced Functions
In Hour 5, Functions, you learned the fundamentals of working with functions. Now that you know how pointers and references work, there is more you can learn to do with functions. In this hour you will learn the following:
How to overload member functions
How to write functions to support classes with dynamically allocated variables
Overloaded Member Functions
In Hour 5, you learned how to implement function polymorphism, or function overloading, by writing two or more functions with the same name but with different parameters. Class member functions can also be overloaded.
The Rectangle class, demonstrated in Listing 13.1, has two DrawShape() functions. One, which takes no parameters, draws the Rectangle based on the class's current values. The other takes two values, a width and a length, and draws the Rectangle based on those values, ignoring the current class values.

 
< previous page page_193 next page >

If you like this book, buy it!