Operator Overloading in C++ Language (part 1)

Operator Overloading in C++ Language



What is Operator Overloading in C++ Language ?





Why is Operator  Overloading used ?

You can write any C++ program without the knowledge of operator overloading. However, operator operating are profoundly used by programmers to make program intuitive. For example,

You can replace the code like:

Calculation = add(multiply (a, b), divide(a, b));
To
Calculation = (a*b)+(a/b);

Rule of Operator Overloading




Example :


operator overloading in c, operator overloading in c++
Operator Overloading


 Remember, in the example given above, whenever we use the operator as a function name in our program then we have to use operator keywords before operator like +,- etc. But while calling the function, we can call in two ways as we are looking at the example above i.e "c3=c1.operator+(c2) or
c3=c1+c2".

If this article is helpful to you then please like share and comments..thank you..

Comments

Popular posts from this blog

Notepad, Wordpad and Paint

HOW TO PASS CCC EXAM WITH ONE ATTEMPT (NIELIT)

Inheritance in C++ Language(part 1)