“function”:纯说明符或抽象重写说明符只允许在虚函数上使用
非虚拟函数被指定为纯 virtual
。
下面的示例生成 C2253:
// C2253.cpp
// compile with: /c
class A {
public:
void func1() = 0; // C2253 not virtual
virtual void func2() = 0; // OK
};
下面的示例生成 C2253:
// C2253_2.cpp
// compile with: /clr /c
ref struct A {
property int Prop_3 {
int get() abstract; // C2253
// try the following line instead
// virtual int get() abstract;
void set(int i) abstract; // C2253
// try the following line instead
// virtual void set(int i) abstract;
}
};