Wednesday, July 18, 2012

Creating classes in C++ can be thought of as creating an entirely new data type--just like an integer or a double--except more powerful. The C++ string class is a great example of using a class to create a data type that is far more convenient and useful than the original C-style implementation of strings
 
In order for C++ types to be equivalent in power to native types, you have to be able to make them work naturally. If it's OK to say that 2 + 2 = 4, why can't you say that "Hello, " + "world" = "Hello, world"? It turns out that you can--by using a feature of C++ called operator overloading.
 
Operator Overloading - Learn how to create overloaded operators to make your classes easier and more natural to use

0 comments:

Post a Comment