Day 10. Working with Advanced Functions
On Day 5, “Organizing into Functions,” you learned the fundamentals of working with functions. Now that you know how pointers and references work, you can do more with functions.
Today, you will learn
• How to overload member functions
• How to overload operators
• How to write functions to support classes with dynamically allocated variables
Overloaded Member Functions
On Day 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 be overloaded as well, in much the same way.
The Rectangle
class, demonstrated in Listing 10.1, has two DrawShape()
functions. One, which takes ...
Get Sams Teach Yourself C++ in 21 Days , 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.