template <class T>
class A {
struct B {
T a,b;
}
B& operator+ (B & x, B & y) {
return B(x.a + y.a, x.b + y.b);
}
int funcA (B & x, B & y){
return (x + y).a;
}
};
As you might guess, during compilation I get "operator+ must take either zero or one argument". Right. Because in the operator+ the "this" is passed as first argument. So, the a solution is to locate the operator outside of the class A definition. However A's function funcA uses operator+. So it has to be defined before A. But operator+ itself uses class B defined in the A which is a template itself and B is dependent class.
What's the solution?