class MyClass {
public:
MyClass(int){}
};
MyClass operator +(MyClass& lOperand, MyClass& rOperand) {
return lOperand;
}
int main() {
MyClass obj1(0);
obj1 = obj1 + 2; // 1
}
Here compiler says no match function of operator + in line 1. But I think 2 can be converted to a MyClass object as the constructor of MyClass is not explicit. If I take & away from the parameter, then it is OK.