Skip to Main Content
Practical C++
book

Practical C++

by Rob McGregor
August 1999
Beginner to intermediate content levelBeginner to intermediate
912 pages
15h 44m
English
Que
Content preview from Practical C++

Chapter 14. Overloading Operators

<feature>
  • Discover reasons for overloading operators

  • Learn how an operator is like a function call

  • Find out how to overload operators

  • See some examples of operator overloading

</feature>

Why Overload Operators?

Operators form the basis of many expressions in C+ statements, working with the built-in C++ data types to aid us in writing code that’s easy to understand, modify, and maintain. Remember the overloaded Multiply() functions back in Chapter 8? Those functions were written to demonstrate how function overloading works, but they aren’t really very useful for real-world code. Imagine if you actually had to use functions like this to perform multiplication:

// z = x * y // int x = 5, y = 10; int z = Multiply(x, y); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical C++ Programming, 2nd Edition

Practical C++ Programming, 2nd Edition

Steve Oualline
C++ Cookbook

C++ Cookbook

D. Ryan Stephens, Christopher Diggins, Jonathan Turkanis, Jeff Cogswell

Publisher Resources

ISBN: 0789721449Purchase book