I have written a relational operator < as member of class Test
bool Test::operator<(const Test& t) { if (a<t) return true; } this code is in the header file, which I have included in my .cpp. However, when I compile my program, I get the following error:
test.h: 134:6: error: ‘a’ was not declared in this scope Where do I declare 'a'? should I write it in my header file as Test& a? can you please help me fix this. thx!
asupposed to be? A data member of classTest? And why are you comparing it against aTestobject?aina<t. So are we. Please explain.x < yinvokesx.operator<(y)... so you need to compare your argumenttto the instance itself.*self<twould be circular. :-)this(not "self") :-)