views:

1507

answers:

6

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

A: 

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.

hayalci
+2  A: 

I think you should look at this question.

GSerg
+11  A: 

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

Laurent
A caution on the advice to not use managed c++ for new projects. From Visual Studio 2008 onwards Managed c++ has some features that are superior to c#. These relate to the handling of IDisposable objects. See http://msdn.microsoft.com/en-us/library/ms235315.aspx
morechilli
Managed C++ and C++/CLI are two different beasts. Managed C++ is a hideous extension to C++ that should never have seen the light of day. C++/CLI is officially a separate language, so new keywords can be added, and is much nicer to work with.
Eclipse
+1  A: 

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

TraumaPony
A: 

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.

radu_c
A: 

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 workes 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 convience, as native code will run faster.