Write a program to overload ‘-’ operator
Answers
Answered by
0
Explanation:
To overload an operator, a special operator function is defined inside the class as:
class className
{
... .. ...
public
returnType operator symbol (arguments)
{
... .. ...
}
... .. ...
};
Here, returnType is the return type of the function.
The returnType of the function is followed by operator keyword.
Symbol is the operator symbol you want to overload. Like: +, <, -, ++
You can pass arguments to the operator function in similar way as functions.
Similar questions
Computer Science,
4 months ago
Hindi,
8 months ago
Chemistry,
11 months ago
Business Studies,
11 months ago