Series: Subject: Topic:
Question: 278 of 339

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

Asked by: Interview Candidate | Asked on: Dec 26th, 2005
Showing Answers 1 - 6 of 6 Answers
Basham ayyappa kumar

Answered On : Jan 23rd, 2006

operator overloading in c++ language provides major using operator overloading we can easily acces the objects to perform any operations .  

Yes  2 Users have rated as useful.
Login to rate this answer.

Answered On : 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.

Yes  3 Users have rated as useful.
Login to rate this answer.

Answered On : Mar 4th, 2006

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

Yes  3 Users have rated as useful.
Login to rate this answer.

Answered On : 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.

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Jul 31st, 2006

View all answers by luckshme

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*/ }

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Jan 30th, 2009

View all answers by Nisikant

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. */

Yes  1 User has rated as useful.
Login to rate this answer.

Give your answer:

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

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.