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

What is the use of Operator Overloading?

Answer Posted / ben jacob

Operator Overloading helps users/developers use a particular
class in an intuitive manner for different kind of
operations logically possible on the class.
It's used for ease of code read and maintainability.

e.g. Date 'b' can be subtracted from another instance of
Date, say 'a', to get the difference in number of days
between the two days.
So, you would overload the subtraction operator '-' for the
Date class accordingly.
Date a("07/04/2008);
Date b("05/04/2008);

//operator overoading for '-' for Date
//returns number of days
int Date::operator-(const Date& rhsDate)
{
//wotever logic
return <number of days between the (this) date and rhsDate>
}

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a pure virtual function?

1431


Explain the rationale behind object oriented concepts?

1179


How can we restrict inheritance for a class so that no class can be inherited from it?

1028


what is full form OOP?

995


What is polymorphism and abstraction?

1017


Explain about inheritance hierarchies?

912


Explain about the relationship between object oriented programming and databases?

888


What do you mean by "explicitly implemeting an interface". Give an example?

951


Define exceptions?

876


Can we reduce the visibility of the inherited or overridden method ?

962


Write down how will you create a Binary tree?

956


Explain what is an object?

916


Can I implement polymorphism using abstract class?

927


How do we implement serialization actually?

889


What is operator overloading?

1286