Difference between managed C++ and C++

C++Visual C++Programming LanguagesManaged C++

C++ Problem Overview


The second question is: When do I use what of these two?

C++ Solutions


Solution 1 - C++

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).

Solution 2 - C++

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

Solution 3 - C++

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 CIL (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.

Solution 4 - C++

I think you should look at this question.

Solution 5 - C++

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.

Solution 6 - C++

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnutarioView Question on Stackoverflow
Solution 1 - C++LaurentView Answer on Stackoverflow
Solution 2 - C++TraumaPonyView Answer on Stackoverflow
Solution 3 - C++Wade NelsonView Answer on Stackoverflow
Solution 4 - C++GSergView Answer on Stackoverflow
Solution 5 - C++radu_cView Answer on Stackoverflow
Solution 6 - C++hayalciView Answer on Stackoverflow