Question

The topics title is actually my question. And the second question is: When do I use what of these two?

Was it helpful?

Solution

When not specified, C++ is unmanaged C++, compiled to machine code. In unmanaged C++ you must manage memory allocation manually.

Managed C++ is a language invented by Microsoft, that compiles to bytecode run by the .NET Framework. It uses mostly the same syntax as C++ (hence the name) but is compiled in the same way as C# or VB.NET; basically only the syntax changes, e.g. using '->' to point to a member of an object (instead of '.' in C#), using '::' for namespaces, etc.

Managed C++ was made to ease transition from classic C++ to the .NET Framework. It is not intended to be used to start new projects (C# is preferred).

OTHER TIPS

"Managed C++" refers to a language that was included in Visual Studio.NET/VisualStudio.NET 2003. It has since been deprecated, with the latest .net C++ being C++/CLI.

You can code native C++ two different ways. The first is compiling directly to machine code with just the operating system between you and the Platform ( Hardware ). The second native coding is done with MFC ( Microsoft Foundation Classes ). This is the same as the first example except for the use of MFC.

Managed C++ uses the CLR ( Common Language Runtime ) The CLR along with the .net framework class libraries make up the .NET Framework. This managed C++/CLI standard uses the .Net framework along with the MSIL ( Microsoft Intermediate Language ). This standard works by mapping to machine code only when the program is executing by the use of a just in time compiler. If your code will be running on different hardware platforms the use of managed code will be much easier. As with all thing there is a slight price to pay for convenience, as native code will run faster.

I think you should look at this question.

Managed C++ means that memory allocation, management, garbage collection is handled by the virtual machine. Whereas in "regular" C++ you would have to allocate and deallocate memory.

You'll be using managed C++ when want to use a native C++ class library from managed code. In this case you wrap unmanaged classes in managed C++ ones, then you use them in any CLR language.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top