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

Can you give some examples of tokens?

1120


what three "domains" are considered during analysis modeling?

6963


What is the default access modifier for a class,struct and an interface declared directly with a namespace?

1019


What is the function of dynamic typing?

1159


Do we require parameter for constructors?

1171


When will you use an interface and abstract class?

1039


What are inner classes and what is the practical implementation of inner classes?

936


Explain method overriding.

1141


What are abstract methods?

1051


What is constructor and virtual function? Can we call virtual funciton in a constructor?

1051


Define Data Abstraction. What is its importance?

1035


What is the best tool for modeling and ORM framework

1086


What are the features that are provided to make a program modular?

1135


What is Overloading ? Is it similar to overriding ?

1047


Why we use oops concepts? What is its advantage?

1042