_Scotch_
asked on
Debug assertion in C++ on code ported from VC6 to Visual Studio 2005 ?
Greetings Experts. I have lots of sort compare code that looks like this:
Everything was great ten years ago or whenever this was written and today it barely builds and runs. Right now I'm working on debug assertions (invalid operator <). The problem seems to be hinted at by MSFT here: http://support.microsoft.com/kb/949171
but I can't see that I'm doing anything different?
Everything was great ten years ago or whenever this was written and today it barely builds and runs. Right now I'm working on debug assertions (invalid operator <). The problem seems to be hinted at by MSFT here: http://support.microsoft.com/kb/949171
but I can't see that I'm doing anything different?
...
stable_sort(vCollars.begin(), vCollars.end(), Collar_Compare_Less);
...
And a predicate routine:
bool CMainFrame::Collar_Compare_Less(Collar* a, Collar* b) {
TRACE("Option a: %x, b: %x --- %d\r\n", a, b, ++bFoo);
if (strcmp(a->cc->callSold->stock, b->cc->callSold->stock) == 1)
return true;
if (a->cc->callSold->strike > b->cc->callSold->strike)
return true;
if (a->cc->callSold->dtg > b->cc->callSold->dtg)
return true;
if (a->premium_percent > b->premium_percent)
return true;
return false;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My blind guess... Is the CMainFrame::Collar_Compare _Less() a static member of the CMainFrame class? Or even the normal method of the class? Try to make it a plain function.
>>if (strcmp(a->cc->callSold->s tock, b->cc->callSold->stock) == 1)
strcmp() returns 0 if two strings are equal. Else non zero.
Refer:
http://www.cplusplus.com/reference/clibrary/cstring/strcmp/
strcmp() returns 0 if two strings are equal. Else non zero.
Refer:
http://www.cplusplus.com/reference/clibrary/cstring/strcmp/
Not exactly. The strcmp() indicates also what of the strings is greater/smaller then the other. The truth is that it says nothing about 1:
So that you may wanted to write > 0 instead of == 1
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.
So that you may wanted to write > 0 instead of == 1
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry for the delay