“identifier”:无法将函数定义与现有的声明匹配
在没有括号的函数调用前面使用了不寻常的一元 + 运算符。
此错误仅发生在 C++ 项目中。
以下示例生成 C2244:
// C2244.cpp
int func(char) {
return 0;
}
int func(int) {
return 0;
}
int main() {
+func; // C2244
}
当为类模板的成员函数使用了不正确的函数签名时,也可能发生 C2244。
// C2244b.cpp
// compile with: /c
template<class T>
class XYZ {
void func(T t);
};
template<class T>
void XYZ<T>::func(int i) {} // C2244 wrong function signature
// try the following line instead
// void XYZ<T>::func(T t) {}
当为成员函数模板使用了不正确的函数签名时,也可能发生 C2244。
// C2244c.cpp
// compile with: /c
class ABC {
template<class T>
void func(int i, T t);
};
template<class T>
void ABC::func(int i) {} // C2244 wrong signature
// try the following line instead
// void ABC::func(int i, T t) {}
无法部分专用化函数模板。
// C2244d.cpp
template<class T, class U>
class QRS {
void func(T t, U u);
};
template<class T>
void QRS<T,int>::func(T t, int u) {} // C2244