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
Math,
5 months ago
India Languages,
5 months ago
Physics,
5 months ago
Hindi,
10 months ago
Chemistry,
1 year ago
Business Studies,
1 year ago