What is the use of Operator Overloading?

Showing Answers 1 - 7 of 7 Answers

Yogesh Panda

  • Sep 19th, 2005
 

By the use of the Oprater overloading we can do the arithematic operation on the user define data types as class,structers.

  Was this answer useful?  Yes

whenkeys

  • Aug 11th, 2008
 

Do any operation symbolizing the operator in your class.

you can add/subtract/multiply/divide or do any other operation for +operator() the choice is entirely yours.

Freedom you see

Feature of operator overloading has been given, to make your class' behaviour as close as to basic datatype.

As in case of basic data type, you can say:
int i = 5;
int i1 = j = k = 6;
int k1 = 6.5;

k1 = 'A';
k2 = k1 = i1;
cout << k1 << endl;
j = k1+k2;


Similarly, you can use operator overloading feature by implementing + / = / cout etc so that your objects also can behave like normal int or any other basic datatype.

Pl Note, Op Overloading is not just for Mathematical operations, but for other operations too, like COUT / NEW / DELETE / [] / (), ofcourse with help of friend functions. 

  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