Overloading Operator in c++
Overloading Operator in c++
OPERATORS IN C++
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. C++ is rich in built-in operators
and provide the following types of operators −
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Misc Operators
WHAT IS OPERATOR OVERLOADING?
C++ has the feature to bridge-in the gap between the user-defined
data-type variables and built-in data-type variables, by allowing us
to work on both type of variables in a same way by the concept
of operator overloading.
For example, we could add two built-in data type int variables by just
using the + operator between these two int variables
(int a+ int b= int c)
1.Private members value1 and value2: These hold integer values for each object.
2.Function setValues: Allows setting the values of value1 and value2 for each object.
4.Display function: Prints the values of the object's value1 and value2.
Here the addition operator that can be used to add two Box objects and returns final Box
object.
Questions?????