Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

why to use operator overloading

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.

2205


What is the real life example of polymorphism?

1129


assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).

2087


Why is polymorphism used?

1008


What is static in oop?

1040


What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }

2527


What are classes oop?

987


Why multiple inheritance is not allowed?

1103


What is an example of genetic polymorphism?

1137


What is polymorphism and example?

1004


Why is polymorphism needed?

1025


What is pointer in oop?

989


IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?

2033


What is pure oop?

1057


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

2099