|
Overview C++/CLI is the newer language specification due to supersede Managed Extensions for C++. Completely reviewed to simplify the older Managed C++ syntax, it provides much more clarity over code readability than Managed C++. It is currently only available on Visual Studio 2005 Beta editions. // Overview Managed Extensions for C++ is a set of keywords and attributes to bring the C++ syntax and language to the . ...
Visual Studio 2005 is the latest development suite from Microsoft, due for release during the week beginning 7th November 2005. ...
One of the most visible improvements is the elimination of ambiguous identifiers. For example, in MC++, there were two different types of pointers: __nogc pointers were normal C++ pointers, while __gc pointers referred to .NET reference types. In C++/CLI the only type of pointer is the normal C++ pointer, and the .NET reference types are accessed through a "handle", with the new syntax ClassName^ instead of ClassName*. The importance of this change becomes crucial when managed and unmanaged code is mixed: where you previously saw a sea of pointers, you can now tell which objects are under garbage collection and which must be destroyed. Other conflicting syntaxes, such as the multiple versions of operator new() in MC++ have been split: in C++/CLI, .NET reference types are created with the new keyword gcnew. Also, C++/CLI has introduced the concept of generics (similar to unmanaged C++ templates, but quite different). // Managed extensions for C++ #using <mscorlib.dll> using namespace System::Collections __gc class referencetype { protected: String* stringVar; int intArr __gc[]; ArrayList* doubleList; public: referencetype(String* str, int* pointer, int number) // Which one is managed? { doubleList = new ArrayList(); System::Console::WriteLine(str->Trim() + number.ToString()); } }; // C++/CLI #using <mscorlib.dll> using namespace System::Collections::Generic ref class referencetype { protected: String^ stringVar; array<int> intArr; List<double>^ doubleList; public: referencetype(String^ str, int* pointer, int number) // Ambiguous no more { doubleList = gcnew List<double>(); System::Console::WriteLine(str->Trim() + number); } }; |