Hour 14. Calling Advanced Functions

Overloaded Member Functions

In Hour 5, “Calling Functions,” you learned how to implement function overloading by writing multiple functions with the same name but different parameters. Member functions also can be overloaded.

This is demonstrated by the Rectangle program in Listing 14.1, which implements a Rectangle class that has two drawShape() functions. One takes no parameters and draws the Rectangle based on the object’s current values. The other takes two values, width and length, and draws a rectangle using those ...

Get Sams Teach Yourself C++ in 24 Hours, fifth edition 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.