KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
If I have a user-defined operator+() as in: class A { public: A operator+(A) { return A(); } }; Then the following works as expected: A a = A() + A(); but g++-4.7 gives an error message on the following: A a = (A()) + A(); The error message in particular is error: no match for ‘operator+’ in ‘+A()’ . It looks like the (A()) is being ignored in the expression. My question is: is A a = (A()) + A(); supposed to compile and if not, why not? Note: this happened to me when I did #define X (Identity()) and then tried doing X + X .
Tags (comma-separated)
Save Edits
Cancel