Computer Science, asked by Hercules6946, 8 months ago

Write a program to overload ‘-’ operator

Answers

Answered by avinashkumar288
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