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?



What is the use of Operator Overloading?..

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

More OOAD Interview Questions

Can you define OOP and principles of OOP?

0 Answers   MindCracker,


How to differentiate between a CreateObject() and GetObject() ?

0 Answers   CGI,


Are constructors inherited? Can a subclass call the parent's class constructor? When?

0 Answers  


What are the tools you used for OOAD?

3 Answers   Protech,


Explain about inheritance?

0 Answers  


Can you use virtual, override or abstract keywords on an accessor of a static property?

0 Answers  


Why is OOP good?

0 Answers  


What is meant by “abstract interface”?

0 Answers  


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

0 Answers  


What is bootstrap, extension and system class loader? Or can you explain primordial class loader?

0 Answers  


What is operator overloading?

1 Answers  


What do you mean by Realization?

1 Answers   Protech,


Categories