开发者

Whats the difference between C++ and C++ CLI [duplicate]

This question already has answers here: What is the difference between ANSI/ISO C++ and C++/CLI? (2 answers) Closed 6 years ago.

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.


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 allows you to have access to the .net framework.

It offers some garbage collection and few other specific features not on 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜