Export (0) Print
Expand All

17 __abstract Keyword

Visual Studio .NET 2003

The __abstract keyword can only be applied to a __gc class or __gc interface. This indicates that it must be further derived from before an object can be constructed. Definitions for any or all member functions can be provided.

Example

// mcpp__abstract.cpp
// compile with: /clr
#using <mscorlib.dll>
__gc __interface IFC { void f(); };

__abstract __gc struct A : IFC { 
   void f() {}
};
__gc struct B : IFC {
   void f() {}
};

int main() {
   // A *pA = new A; // error: A is abstract
   B *pB = new B; // ok
}

Characteristics

  • The __abstract keyword on a __gc class or __gc interface just indicates that it cannot be instantiated directly. It has no effect on the members of the class or interface, for example whether or not they are pure virtual functions.

Constraints

The following restrictions apply to abstract classes.

  • The __abstract keyword shall not be applied with the __value keyword.
  • The __abstract keyword shall not be applied with the __sealed keyword.

The __abstract keyword on an interface is redundant, but is allowed.

Show:
© 2014 Microsoft