C++ 和有什么区别?和 C++命令行界面
我正在学习 C++(显然是 CLI),每次我发布一个问题说我正在使用 C++ 时,就会有人跳下来说我没有使用 C++,而是 C++/CLI。我不太确定有什么区别,因为我对此非常陌生,但这似乎让每个人都感到不安。任何人都可以阐明这些差异吗?
第二点,我问这个问题的原因是因为有人建议我使用 CLI 来使我的 C# 项目可以访问方法。通过我的构造函数,我的 C++ 项目中的所有内容都运行良好,但现在我希望能够从我的 C# 项目中调用相同的方法。
I'm learning C++ (CLI apparently), and every time I post a question saying that I am using C++, someone jumps down my throat saying that I'm not using C++, but C++/CLI. I'm not really sure of a difference, as I am extreamely new to this, but it seems to make everyone upset. Can anyone shine some light on the differences?
As a second note, the reason I am asking this is because it was suggested that I use CLI to be able to make a method accessible to my C# project. I have everything running fine in my C++ project, through my constructor, but now I would like to be able to call those same methods from my C# project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
C++ CLI 在“公共语言界面”上运行。这基本上意味着在编译时,编译后的代码最终将像通过 C# 生成的字节代码一样进行分配。
C++ CLI 添加了大量扩展,例如 C++ 中不存在的垃圾收集。 C++ CLI 还允许“安全”C++ 代码。在此模式下您不允许使用指针。 C++ 中不存在“安全”代码,都是“不安全”的。 C++ CLI 非常适合连接 .NET 代码和 C++ 库,但除此之外,我还没有发现它的用途。
维基百科页面有很好的概述:http://en.wikipedia.org/wiki /C%2B%2B/CLI
是的,他们对你的攻击是正确的,因为能够在 C++ CLI 中编程将不允许你在 C++ 中编程....它们足够不同,以至于你不能只是混合它们。
C++ CLI runs on the "Common Language Interface". This basically means that when it's compiled, the compiled code will end up being allot like the byte code produced via C#.
C++ CLI has a ton of extensions added to it such as Garbage Collection that do not exist in C++. C++ CLI also allows for "safe" C++ code. In this mode you're not allowed to use pointers. There's no such thing as "safe" code in C++ it's all "unsafe". C++ CLI can be nice for interfacing .NET code and C++ libraries, but besides that, I haven't found a use for it.
The Wikipedia page has a good overview: http://en.wikipedia.org/wiki/C%2B%2B/CLI
And yes, they are right to jump on you for being able to program in C++ CLI will not allow you to program in C++....they are different enough that you cant just mix them.
AFAIK,C++ CLI 允许您访问 .net 框架。
它提供了一些垃圾收集和一些 C++ 上没有的其他特定功能
AFAIK, C++ CLI allows you to have access to the .net framework.
It offers some garbage collection and few other specific features not on C++
C++ 直接作为针对您的硬件编译的二进制文件运行。 C++ cli 是一个 C++ 扩展,用于与 MS 公共语言运行时交互。它通常符合 IL 并在 .net 运行时内执行。两者之间存在许多差异,其中一些主要差异是垃圾收集以及继承和接口的工作方式。
使用 c++Cli 的原因是获得使用框架提供的数百个类的优势。这些都可以从任何符合 CLR 的语言访问,因此有些人想知道为什么要使用 C++ 来访问框架,除非您链接到一些遗留代码。
C++ runs directly as binary complied for your hardware. C++ cli is a c++ extension that is used to interface with the MS common language runtime. It complies to IL normally and is executed inside the .net runtime. There are numerous differences between the two some of the major ones being garbage collection and how inheritance and interfaces work.
The reason to use c++Cli is gain the advantages of using the hundreds of classes provided to you by the framework. These are all accessible from any CLR compliant language so some have been left to wonder why one would use c++ to access the framework, unless you are linking into some legacy code.