Declares a class that cannot be instantiated directly.
__abstract class-specifier __abstract struct-specifier
The __abstract keyword declares that the target class can only be used as a base class of another class. Applying __abstract to a class or structure does not imply that the result is a managed class or structure.
Differing from the C++ notion of an abstract base class, a class with the __abstract keyword can provide function definitions for all of its member functions.
Note The __abstract keyword is illegal when used with the __value or __sealed keyword and redundant with __interface keyword.
In the following example, the Derived
class is derived from an abstract base class (Base
). Instantiation is then attempted on both but only Derived
is successful.
#using <mscorlib.dll> #using namespace System; __abstract __gc class Base { int BaseFunction() { return 0; } }; class __gc Derived: public Base { }; void main() { Base MyBase; //Error: cannot instantiate an abstract class Derived MyDerived; }
Managed Extensions for C++ Keywords | __value | Delegates in Managed Extensions for C++ | C++ Keywords