Can there be multiple definitions of an overloading operator in a class?

Can there be multiple definitions of an overloading operator in a class? Like there are overloading constructors...

Would this be valid code and will it work/compile?

1
2
3
4
5
6
7
8
9
class myclass {
public:
    int a;
    int b;
    myclass(){a=0,b=0};
    myclass operator+ (myclass);
    myclass operator+ (int);
    myclass operator+ (float);
};
yeap!
In addition I would suggest you read up on operator overloading - there is a catch when dealing with
binary operators (those operators that take 2 operands such as addition )
Last edited on
Topic archived. No new replies allowed.