Why am I allowed to do this, why there is no ambiguity complain, and why is the class' method chosen with prior to the other one?
class EX { public: //... void operator+(const EX& ref) { cout << "A"; } }; void operator+(const EX& ref1, const EX& ref2) { cout << "B" << endl; } int main() { EX obj1{20}; EX obj2{30}; cout << "obj1 + obj2 = " << obj1 + obj2 << endl; return 0; } I was expecting the global function operator+ to be called an "B" printed on the screen, instead "A" was printed.