C ++与C ++。NET之间的主要区别是什么?

问题描述:


可能重复:

托管C ++和C ++ / CLI有什么区别?

CLI / C ++到底是什么?

我怀疑

是正确的C ++是非托管代码,而C ++。NET是托管代码吗?

Is that right C++ is unmanaged code and C++.NET is managed code?

我需要用C ++为一个项目编程。为了更好地构建GUI,我更喜欢使用C ++。NET。

I need to program for a project in C++. For better building the GUI, I would prefer to use C++.NET.

我还有另一个普通的C ++库(非托管C ++ DLL文件),是否可以使用

I also have another plain C++ library (unmanaged C++ DLL file), will it be possible to use it as a normal DLL library in the C++.NET project?


它是正确的C ++吗?非托管代码,而C ++。NET是托管代码。

Is that right C++ is unmanaged code and C++.NET is managed code.

没有 C ++。NET之类的东西。有C ++ / CLI,基本上是带有Microsoft扩展程序的C ++,可让您编写针对.NET框架的代码。 C ++ / CLI代码编译为CLR字节码,并像C#一样在虚拟机上运行。我假设您实际上是在谈论C ++ / CLI。

There's no such thing as "C++.NET". There's C++/CLI, which is basically C++ with Microsoft extensions that allow you to write code targeting the .NET framework. C++/CLI code compiles to CLR bytecode, and runs on a virtual machine just like C#. I'll assume you're actually talking about C++/CLI.

关于这一点,可以说标准C ++是不受管的,而C ++ / CLI是受管的,但这就是非常多的Microsoft术语。除非与C ++ / CLI相比,否则在谈论标准C ++时,您永远不会看到这样使用非托管一词。

With respect to that, one can say standard C++ is unmanaged and C++/CLI is managed, but that's very much Microsoft terminology. You'll never see the term "unmanaged" used this way when talking about standard C++ unless in comparison with C++/CLI.

标准C ++和C ++ / CLI都可以由相同的Visual C ++编译器编译。前者是VC ++编译器的默认设置,而需要编译器开关才能使其在后者模式下进行编译。

Both standard C++ and C++/CLI can be compiled by the same Visual C++ compiler. The former is the default on VC++ compilers, while a compiler switch is needed to make it compile in latter mode.


我需要进行编程C ++中的一个项目。为了更好地构建GUI,我
倾向于使用C ++。NET。

I need to program for a project in C++. For better building the GUI, I would prefer to use C++.NET.

您可以仅使用C ++构建GUI程序以及C ++ / CLI。这更加困难,因为在标准C ++中没有像.NET框架那样用于构建GUI的标准库,但是有很多项目,例如 Qt wxWidgets ,它们提供了C ++ GUI框架。

You can build GUI programs in C++ just as well as C++/CLI. It's just harder because there isn't a standard library in standard C++ for building GUI like the .NET framework has, but there are lots of projects out there like Qt and wxWidgets which provide a C++ GUI framework.

我也有另一个普通的C ++库(非托管C ++ dll),是否可以将
用作C ++。NET项目中的普通dll库?

I also have another plain C++ library (unmanaged C++ dll), will it be possible to use it as a normal dll library in the C++.NET project?

是。处理不同的标准C ++数据类型和.NET数据类型可能需要一些额外的工作,但是您当然可以使它工作。

Yes. It might take some extra work to deal with the different standard C++ data types and .NET data types, but you can certainly make it work.