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

What is the main difference between C++ vs C++.NET?(C++ 与 C++.NET 之间的主要区别是什么?)

本文介绍了C++ 与 C++.NET 之间的主要区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
托管 C++ 和 C++/CLI 有什么区别?
CLI/C++ 到底是什么?它与普通"c++ 有何不同?

我怀疑区分 C++ 和 C++.NET.

I am in doubt of distinguishing between C++ and C++.NET.

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 文件),是否可以将它用作 C++.NET 项目中的普通 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++ 和 C++/CLI 构建 GUI 程序.只是更难,因为标准 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.

这篇关于C++ 与 C++.NET 之间的主要区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:C++ 与 C++.NET 之间的主要区别是什么?

基础教程推荐