why to use operator overloading

Answers were Sorted based on User's Feedback



why to use operator overloading..

Answer / chandra

to achieve synchronization with the normal languages like c.
for example int a=10,b=30,c;
c = a+b ;
the above operation is possible in c as well as c++.bcos
the variables declared are primitive types.

If u want to do same thing for user defined datatypes, i
can say objects, we have to overload the operators.

For ex:
Assume that u created one class
Class A
and u have created objects
A obj1(10),obj2(30),obj3;

and u want the add 2 objects and result must be stored in
another object.

then u have to overload the operator + for class A.

obj3 = obj1 + obj2 ;

Is This Answer Correct ?    7 Yes 0 No

why to use operator overloading..

Answer / rekha

Operator overloading means giving additional meaning to
existing operators

Operators are defined to perform some operation on
fundamental types .Operator cannot work with user defined
types like classes and struct.so concept of operator
overloading means allows defining the meaning of operator so
that the can be used for performing operations on user defined
types.

Is This Answer Correct ?    3 Yes 0 No

why to use operator overloading..

Answer / r.ramakrishna

BY using the operator overloading we can the more than one
operator in single function.

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More OOPS Interview Questions

What does <> mean pseudocode?

0 Answers  


What is difference between data abstraction and encapsulation?

0 Answers  


what is the difference between function template and template of function?explain with example.

2 Answers  


what is difference between c++ language and java language

5 Answers  


What do you mean by public, private, protected and friendly?

3 Answers   CA,






Write a macro for swapping integers

5 Answers  


what is inline function?

3 Answers  


given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

0 Answers   DELL,


What is advantage of inheritance?

0 Answers  


When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??

13 Answers   HCL, Honeywell,


What is the diamond problem in inheritance?

0 Answers  


How to create a comment page in C #??

2 Answers  


Categories