Normally when you declare a method within a class declaration, and define it outside, you need to specify its scope.
Since I've read that operators are pretty much regular methods, I find it hard to understand the following behavior:
class A
{
public:
    A(int x)
    { this->x = x;}
    int foo();
    friend const A operator+ (const A& left,const int right);
private:
    int x;
};
const A operator+ (const A& left,const int right) //can't be A::operator+
{
    return A(left.x + right);
}
int A::foo()  // A:: is needed here
{
    return 5;
}
int main(int argc, char **argv) {
    A a(1);
    a = a + 4;
    a.operator =(a+5);
    a.foo();
}
Why don't we need to specify which "operator+" we're defining\overloading? Is it inferred from the operands?
 
     
     
     
     
    