编译器错误 C3299
“member_function”:无法指定约束,因为它们都继承自基方法
替代泛型成员函数时,无法指定约束子句(重复约束意味着未继承约束)。
将继承正在替代的泛型函数上的约束子句。
有关详细信息,请参阅泛型类型参数的约束 (C++/CLI)。
示例
下面的示例生成 C3299。
// C3299.cpp
// compile with: /clr /c
public ref struct R {
generic<class T>
where T : R
virtual void f();
};
public ref struct S : R {
generic<class T>
where T : R // C3299
virtual void f() override;
};