Difference between managed C++ and C++ [closed]
The second question is: When do I use what of these two?
Solution 1:
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:
"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:
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:
I think you should look at this question.
Solution 5:
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.