I tested myself a bit:
#include <iostream>
#include "MyClass.h"
using namespace std;
MyClass operator +(const MyClass& a, const MyClass& b)
{ cout << "external" << endl; return a; }
int main() {
MyClass foo, bar;
foo + bar;
return 0;
}
class MyClass {
public:
MyClass operator+(const MyClass& a) { cout << "internal" << endl; return a; }
};
The output of the program was "internal." My conclusion is that if there is an internal operator that is suitable for the operation, it will be one. I do not see the possibility of making the external, if the internal fits better. But I should note that I just did a little test and did not find out that this is a 100% answer.
source
share