unary overload operator cpp

Solutions on MaxInterview for unary overload operator cpp by the best coders in the world

showing results for - "unary overload operator cpp"
Doyle
21 Jun 2017
1class A {
2public:
3    int value;
4    A(int v1) : value(v1) {};
5    // overloaded minus (-) operator
6    A operator- () {
7        return A(-value);
8    };
9};