//Class definition
class Type1 {...};
class Type2 {...};
class A
{
public:
...
void Func1(Type1* t1.....);
void Func1(Type2& t2.....);
...
};
//Using Func1 function
A obj;
Type2 t2;
...
obj.Func1(t2,...);
...This code successfully compiles in the 32-bit mode but the compiler generates the error C2664 (Type2 cannot be cast to Type1*) when trying to build the 64-bit version. Although the function taking Type2& as the argument is defined, the compiler, due to some reason, tries to use the function taking Type1* as the argument. What is the matter?Most likely, the problem is in the other parameters which were replaced by dots in the example. Here is one more example of the code:
class Type1 {};
class Type2 {};
class A
{
public:
void Func1(Type1* t1, unsigned &);
void Func1(Type2& t2, size_t &);
};
void use() {
A obj;
Type2 t2;
unsigned u;
obj.Func1(t2, u);
}It successfully compiles in the 32-bit mode. But in the 64-bit mode the both functions fail to work. The compiler considers the first function a better candidate because its second parameter meets the condition. Yet it announces that the first argument does not suit: error C2664: 'void A::Func1(Type1 *,unsigned int &)' : cannot convert parameter 1 from 'Type2' to 'Type1 *'. The solution is to carefully study the other arguments and modify the code as needed.
Комментариев нет:
Отправить комментарий