The second question is: When do I use what of these two?
Managed Code is converted to IL, Intermiddiate Language also termed as CIL of MSIL. Unmanaged Code is converted to native language code. Programmer has no low level access using Managed Code. Programmer can write low level access code using unmanaged code.
Native code is written in the "native" machine language of the computer that it is running on and is executed directly by the processor. Managed code is written in a special language that requires another program to run (i.e. manage) it.
The C++ compiler actually uses two heaps, a managed an unmanaged one, and uses operator overloading on new to decide where to allocate memory when you create an instance with new.
Managed code uses CLR which in turns looks after your applications by managing memory, handling security, allowing cross - language debugging, and so on. The code, which is developed outside . NET, Framework is known as unmanaged code.
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).
"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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With