FIX: C2678 on Overloaded Functions When Using a NamespaceLast reviewed: September 19, 1997Article ID: Q155164 |
The information in this article applies to:
SYMPTOMSThe wrong version of an overloaded function is called causing the following compiler two errors:
error C2678: binary '!=' : no operator defined which takes a left-hand operand of type 'const struct Test' (or there is no acceptable conversion) (new behavior; please see help) error C2664: 'Tester' : cannot convert parameter 1 from 'const struct Test' to 'const float &' (new behavior; please see help)The sample in the “Sample Code” demonstrates this problem. These errors occur when:
RESOLUTION
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0.
MORE INFORMATIONThe following sample code demonstrates the problem of incorrect overloaded function call causing the C2678 and the C2664 compiler errors.
Sample Code
/* Compile options needed: none
*/
struct Test
{
} ;
// Uncomment the following 2 lines for workaround #1
// namespace Space2
// {
int Tester(const Test& rx, const Test& ry)
{
return 0 ;
}
int operator!=(const Test& rx, const Test& ry)
{
return 0 ;
}
// Uncomment the following line for workaround #1
// }
namespace Space1
{
int operator!=(const float& rx, const Test& rt)
{
return 1 ;
}
int Tester(const float& rx, const int& ri)
{
return 1 ;
}
}
// Uncomment the following line for workaround #2
// using namespace Space1 ;
void main()
{
const Test a ;
const Test b ;
using namespace Space1 ;
if (a != b) ; // This line causes the C2678
Tester(a, b); // This line causes the C2664
}
Keywords : CLIss kbprg Version : 4.0 4.1 4.2 Platform : NT WINDOWS Issue type : kbbug Solution Type : kbfix |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |