Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error C2678: binary '<'

Status
Not open for further replies.

COTLG

Technical User
Apr 15, 2003
107
0
0
US
Hi All,

Please pardon my posting this here. The MS V C++ forumn is not accessible now.

I am getting this error on compiling ErrorType.cpp:

errortype.cpp(43) : error C2678: binary '<' : no operator found which
takes a left-hand operand of type 'const ErrorType' (or there is no
acceptable conversion)

Here is the portion of code:

bool ErrorType::eek:perator<(const ErrorType& right)
{
if((priority < right.priority)||
(priority == right.priority &&
timestamp < right.timestamp)||
(priority == right.priority &&
timestamp == right.timestamp &&
errorCode < right.errorCode))
return true;
else
return false;
}


bool ErrorType::eek:perator>(const ErrorType& right)
{
return right < *this; //line 43
}

I will appreciate any assistance.

Chike.

 
try

return (right < *this);

as the expression will be evaluated before trying to return.

<insert stupid signature here>
 
Take a look of the declaration of this method in the .h file. The declaration and the implementation should match.
obislavu
 
There is no need for a bracket since the operator precedence will ensure correct evalution. I however put the bracket and the error persists.

The function head is the same as in the declaration.

I am carrying out operator overload for a class - ErrorType in this portion of my program.

Thanks.

Chike.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top