Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
Reference
C/C++ Languages
 abstract
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual C++ Language Reference
abstract (Visual C++)

abstract is a context sensitive keyword that can indicate:

  • A member can only be defined in a derived type.

  • A type cannot be instantiated (can only act as a base type).

Marking a function abstract is the same as making it a pure virtual function. Making a member function abstract causes the enclosing class to also be marked abstract.

abstract is also valid when compiling for native targets (without /clr).

See Override Specifiers and Native Compilations for more information.

You can detect at compile time if a type is abstract with __is_abstract(type). For more information, see Compiler Support for Type Traits.

abstract is a context-sensitive keyword; see Context-Sensitive Keywords for more information.

The following sample will generate an error because class X is marked abstract.

// abstract_keyword.cpp
// compile with: /clr
ref class X abstract {
public:
   virtual void f() {}
};

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

The following sample shows that the compiler will generate an error because a native class is marked abstract, when compiled with /clr.

// abstract_keyword_2.cpp
class X abstract {
public:
   virtual void f() {}
};

int main() {
   X * MyX = new X;   // C3622
}

The following sample will generate an error because function f is marked abstract.

// abstract_keyword_3.cpp
// compile with: /clr
ref class X {
public:
   virtual void f() abstract {}   // C3634
   virtual void g() = 0 {}   // C3634
};

Compiler option: /clr

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker