다음을 통해 공유


방법: 네이티브 컴파일에 재정의 지정자를 선언

sealed, abstract, and override are available in compilations that do not use /ZW or /clr.

참고

The ISO C++11 Standard language has the override identifier and the final identifier, and both are supported in Visual Studio Use final instead of sealed in code that is meant to be compiled as native-only.

예제

설명

The following example shows that sealed is valid in native compilations.

코드

// sealed_native_keyword.cpp
#include <stdio.h>
__interface I1 {
   virtual void f();
   virtual void g();
};

class X : public I1 {
public:
   virtual void g() sealed {}
};

class Y : public X {
public:

   // the following override generates a compiler error
   virtual void g() {}   // C3248 X::g is sealed!
};

예제

설명

The next example shows that override is valid in native compilations.

코드

// override_native_keyword.cpp
#include <stdio.h>
__interface I1 {
   virtual void f();
};

class X : public I1 {
public:
   virtual void f() override {}   // OK
   virtual void g() override {}   // C3668 I1::g does not exist
};

예제

설명

This example shows that abstract is valid in native compilations.

코드

// abstract_native_keyword.cpp
class X abstract {};

int main() {
   X * MyX = new X;   // C3622 cannot instantiate abstract class
}

참고 항목

참조

지정자 재정의