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!
You’re supposed to be defining how a Test object may be compared to another object of type Test but in your code you do not define how, only that “a” – whatever that is, is less than the other object.
Then in your program,