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 |
Can you define OOP and principles of OOP?
How to differentiate between a CreateObject() and GetObject() ?
Are constructors inherited? Can a subclass call the parent's class constructor? When?
What are the tools you used for OOAD?
Explain about inheritance?
Can you use virtual, override or abstract keywords on an accessor of a static property?
Why is OOP good?
What is meant by “abstract interface”?
What are inner classes and what is the practical implementation of inner classes?
What is bootstrap, extension and system class loader? Or can you explain primordial class loader?
What is operator overloading?
What do you mean by Realization?