GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 60 of 203    Print  
What is operator overloading?what r the advantages of operator overloading?

  
Total Answers and Comments: 6 Last Update: January 30, 2009     Asked by: santoshMudholam 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: chandana
 

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.


Above answer was rated as good by the following members:
wael.salman, yzesong
January 23, 2006 05:12:24   #1  
Basham ayyappa kumar        

RE: What is operator overloading?what r the advantages...

operator overloading in c++ language provides major advantages.

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


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
January 24, 2006 03:29:38   #2  
chandana        

RE: What is operator overloading?what r the advantages...

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.

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
March 04, 2006 22:59:13   #3  
priya        

RE: What is operator overloading?what r the advantages...
using operator overloading we can perform different operations on the same operands.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
May 28, 2006 03:15:01   #4  
jay        

RE: What is operator overloading?what r the advantages...

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.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
July 31, 2006 01:41:36   #5  
luckshme Member Since: July 2006   Contribution: 3    

RE: What is operator overloading?what r the advantages...

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


 
Is this answer useful? Yes | No
January 30, 2009 06:07:26   #6  
Nisikant Member Since: January 2009   Contribution: 8    

RE: What is operator overloading?what r the advantages of operator overloading?
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. */

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape