编译器错误 C3284
函数“function”的泛型参数“parameter”的约束必须与函数“function”的泛型参数“paramete”的约束匹配
虚拟泛型函数所用的约束必须与基类中具有相同名称和参数集的虚拟函数的约束相同。
以下示例生成 C3284:
// C3284.cpp
// compile with: /clr /c
// C3284 expected
public interface class IGettable {
int Get();
};
public interface class B {
generic<typename T>
where T : IGettable
virtual int mf(T t);
};
public ref class D : public B {
public:
generic<typename T>
// Uncomment the following line to resolve.
// where T : IGettable
virtual int mf(T t) {
return 4;
}
};
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈