Benefits of OOP

With this introduction to C++, you can better understand the advantages that C++ provides over more traditional, non-OOP languages. One of the benefits of OOP is that you can create your own operators. More accurately, you can change the way an operator works when the program uses that operator with one of your objects.

By writing special operator overloading member functions, you can make any C++ operator work on your own objects. For example, a plus sign is the addition operator that automatically works on all numeric values. The plus sign, however, cannot work on a Person object such as Mike. Therefore, if you wanted to add two Person objects together to get a total of the salaries, you could write a function that added the ...

Get Absolute Beginner's Guide to Programming, Second 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.