Index

The .NET Keyword Extensions

To support the .NET managed execution environment, Microsoft adds the following keywords to the C++ language.

_ _abstract

_ _box

_ _delegate

_ _event

_ _finally

_ _gc

_ _identifier

_ _interface

_ _nogc

_ _pin

_ _property

_ _sealed

_ _try_cast

_ _typeof

_ _value

Each of these is briefly described in the following sections.

_ _abstract

_ _abstract is used in conjunction with _ _gc to specify an abstract managed class. No object of an _ _abstract class can be created. A class specified as _ _abstract is not required to contain pure virtual functions.

_ _box

_ _box wraps a value within an object. Boxing enables a value type to be used by code that requires an object derived from System::Object, which is the base class of all .NET objects.

_ _delegate

_ _delegate specifies a delegate, which encapsulates a pointer to a function within a managed class (that is, a class modified by _ _gc).

_ _event

_ _event specifies a function that represents an event. Only the prototype for the function is specified.

_ _finally

_ _finally is an addition to the standard C++ exception handling mechanism. It is used to specify a block of code that will be executed when a try/catch block is left. It does not matter what conditions cause the try/catch block to terminate. In all cases, the _ _finally block will be executed.

_ _gc

_ _gc specifies a managed class. Here, “gc” stands for “garbage collection” and indicates that objects of the class are automatically garbage collected when they are no longer needed. An object is no longer needed when no references to the object exist. Objects of a _ _gc class must be created using new. Arrays, pointers, and interfaces can also be specified as _ _gc.

_ _identifier

_ _identifier allows a C++ keyword to be used as an identifier. This is a special-purpose extension that will not be used by most programs.

_ _interface

_ _interface specifies a class that will act as an interface. In an interface, no function can include a body. All functions in an interface are implicitly pure virtual functions. Thus, an interface is essentially an abstract class in which no function has an implementation.

_ _nogc

_ _nogc specifies a non-managed class. Since this is the type of class created by default, the _ _nogc keyword is seldom used.

_ _pin

_ _pin is used to specify a pointer that fixes the location in memory of the object to which it points. Thus, an object that is “pinned” will not be moved in memory by the garbage collector. As a result, garbage collection does not invalidate a pointer modified by _ _pin.

_ _property

_ _property specifies a property, which is a member function that gets or sets the value of a member variable. Properties provide a convenient means to control access to private or protected data.

_ _sealed

_ _sealed prevents the class that it modifies from being inherited. It can also be used to specify that a virtual function cannot be overridden.

_ _try_cast

_ _try_cast attempts to cast one type of expression into another. If the cast fails, an exception of type System::InvalidCastException is thrown.

_ _typeof

_ _typeof obtains an object that encapsulates type information for a given type. This object is an instance of System::Type.

_ _value

_ _value specifies a class that is represented as a value type. A value type holds its own values. This differs from a _ _gc type, which must allocate storage through the use of new. Value types are not subject to garbage collection.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net