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 |
Why is message passing between the objects important?
What is the default access specifier in a class definition?
Explain OOPS.
How many methods are there in the serializable interface?
What is meant by function overloading and function overriding?
Explain basic concepts of OOPS?
Can you instantiate an abstract class and what is an inner class?
0 Answers Flextronics, Tavant Technologies, Virtusa,
what is meant by "method-wars"?
Explain what is single and multiple inheritance?
Define Destructor?
What is a try/ catch block?
Do we require a parameter for constructors?