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 |
What is the purpose of late binding in object-oriented programming?
What is operator overloading and polymorphism?
0 Answers ITC Indian Tobacco Company,
What is multiple inheritance? How java 8 supports multiple inheritance?
Can we reduce the visibility of the inherited or overridden method ?
What are the different types of inheritance?
Explain about the analysis phase?
Explain about uml?
Explain about message passing in object oriented programming?
Explain about object oriented databases?
What do you mean by Realization?
what is meant by "method-wars"?
Why is C not an OOP language?
0 Answers Agilent, Integreon, ZS Associates,