What is operator overloading?what r the advantages of operator overloading?

Showing Answers 1 - 7 of 7 Answers

Basham ayyappa kumar

  • Jan 23rd, 2006
 

operator overloading in c++ language provides major advantages.

by using operator overloading we can easily acces the objects to perform any operations .

 

 

chandana

  • Jan 24th, 2006
 

Operator overloading:It is one of the features of Object oriented programming which gives an extra ability to an operator to act on a User-defined operand(Objects).

Uses of Operator Overloading:

  • Extensability: An operator will act differently depending on the operands provided.
  • Operator is not limited to work only with primitive Data Type.

priya

  • Mar 4th, 2006
 

using operator overloading we can perform different operations on the same operands.

jay

  • May 28th, 2006
 

The advantage to operator overloading is that it makes code much more readable. and You can override the conversion operators to allow your user-defined types to be converted to either built-in types or other user-defined types.

luckshme

  • Jul 31st, 2006
 

Operators like +, -, *, = etc are internally unary / binary functions that take corresponding parameters. For example, 3+4 is considered as +(3,4) where + is the function name. These functions(operators) come with a default implementation that takes the primitives(int, float etc) as the parameters. If you would want these functions(operators) to work on objects of your own classes, you may choose to implement those features by overloading these functions(operators).

Example: You may write a class named MyClass that will allow to add two objects of the same class. For this you may overload the + function(operator) as follows:

class MyClass {

void +(MyClass &myclass) {/*this class + another object of same class*/ }

Nisikant

  • Jan 30th, 2009
 

When the operator operates on the user defined data type or operands behaves same as it operates on inbuilt data type that mechanism is known as operator overloading. The operator that performs the specific task on inbuilt data type  performs similar task upon the user defined data type.

int x=5, y=6, z;
z= x+y;  ...../* addition operator acts on inbuilt data type for addition porpose. */

class nisi a1,a2,a3;
a3= a1+a2;   ..../* Here it is used to add two objects of class named "nisi" which is user defined data type. */

yunisha pandey

  • Jan 13th, 2015
 

and what are the disadvantages of operator overloading???

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions