Prevents a method or class from being a base class.
__sealed class-specifier __sealed struct-specifier __sealed function-declarator
The __sealed keyword specifies that a class method cannot be overridden or that a class cannot be a base class.
A __sealed virtual method cannot be overridden. A __sealed method cannot be pure.
If a nonvirtual member method is marked __sealed, the __sealed qualification is ignored.
When a class (or struct) is marked with __sealed, the class cannot be used as a base class. For example:
__sealed class A { // ... }; class B : public A { // error // ... };
On a virtual method in a class, __sealed indicates that no other implementation of this function in any derived classes is allowed.
Note The __sealed keyword is illegal when used with the __abstract keyword.
extern "C" int printf(const char*, ...); struct I { virtual void f() { printf("I::f()\n"); } }; struct B1 : I { virtual void f() { printf("B1::f()\n"); } }; struct B2 : I { // the following function cannot be overridden in the vtable __sealed virtual void f() { printf("B2::f()\n"); } }; struct A : B1, B2 { virtual void f() { printf("A::f()\n"); } }; void main() { A* pA = new A; B1* pB1 = new A; B2* pB2 = new A; pA->f(); pB1->f(); pB2->f(); }
Managed Extensions for C++ Keywords | C++ Keywords