Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c++-cli

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.

like image 742
George Johnston Avatar asked Jan 28 '10 19:01

George Johnston


1 Answers

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.

like image 62
Timothy Baldridge Avatar answered Sep 27 '22 20:09

Timothy Baldridge