tags:

views:

215

answers:

4

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.

+1  A: 

Wikipedia's page on C++/CLI has some good information.

Trent
Unlike this answer, which has *zero* information. Please provide a summary, so people reading this may actually find an answer to the question. Simply linking to external resources is considered bad style on SO.
jalf
@jalf, come on now, my answer does have *some* information, it has a link to Wikipedia :). I don't find it difficult to follow a link to get a more complete answer than I could provide.
Trent
First, what if the link is down? gets vandalized? is deleted? Second, someone interested in an answer to this question may want to read more than one answer. If every answer is simply a link to an external resource, then it's suddenly a lot of work. And third, your rep on SO is supposed to represent *your* knowledge and helpfulness. In this case, you have shown *zero* knowledge of your own, and so your post as it stands now warrants a -1 and nothing else.
jalf
You don't have to quote the entire Wiki page, but it is considered helpful to draw out a few key points, so that someone reading this answer will at least have an idea of whether the wiki link is relevant enough to bother clicking on.
jalf
A: 

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.

Timothy Baldridge
A: 

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++

Max
+1  A: 

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.

rerun
You can compile c++ code inside of a cli project as long as you don't use a ref class normal c++ syntax rules apply, and you can certainly link and use standard c++ libraries.
rerun
@Neil:C++/CLI is nearly a superset of C++ (minus things like `export` that most other C++ compilers don't implement either), so most legal C++ will also compile as C++/CLI. That said, virtually all C++/CLI code uses extensions, so it's not even very similar to C++.
Jerry Coffin