Microsoft Visual C++
Microsoft’s latest C++ compiler has a split personality. It can generate a conventional program following the standard (more or less), or it can produce .NET output using a modified language called Managed C++, which restricts some features and adds others. The following are some highlights of the Managed C++ extensions:
_ _boxThe
_ _boxoperator takes a value object as an argument and returns a managed (_ _gc) object that wraps the value in a managed “box.” You can also declare a pointer to a value type with the_ _boxspecifier so the pointer can store boxed values. The compiler treats boxed values specially and lets you access the members of the value transparently, as though the box were not present. Nonetheless, the box manages the lifetime of the value it contains._ _declspecThe
_ _declspeckeyword takes a list of attributes in parentheses and serves as a declaration specifier. Depending on the attributes, it can be used to modify a function, object, or class. See Section A.1 for more information._ _gcThe key feature of Managed C++ is that objects are garbage-collected. This means the lifetime and memory are managed automatically by the runtime environment. As long as the object is in use, it remains alive. When the object is no longer used anywhere in the program, it is up for reclamation.
Declare a class using the
_ _gcspecifier to mark the class as managed. A managed class has numerous restrictions, such as:No more than one base class (which must ...