What is the difference between C ++ and C ++ CLI

I learn C ++ (obviously CLI), and every time I post a question about what I use C ++, someone jumps into my throat saying that I do not use C ++, but C + + / CLI. I'm not quite sure of the difference, as I'm completely new to this, but everyone seems to be upset. Can someone highlight the differences in the differences?

As a second note, the reason I'm asking about this is because it was suggested to use the CLI to make the method available to my C # project . Everything works fine for me in my C ++ project, through my constructor, but now I would like to be able to call the same methods from my C # project.

+4
source share
4 answers

The C ++ / CLI Wikipedia page contains some useful information.

0
source

C ++ CLI runs on the "Common Language Interface". This basically means that during compilation, the compiled code will be allocated as byte code created using C #.

The C ++ CLI has a ton of add-ons added to it, such as a garbage collection, that do not exist in C ++. The C ++ CLI also allows for "safe" C ++ code. In this mode, you are prohibited from using pointers. There is no such thing as “safe” C ++ code; all this is “unsafe”. The C ++ CLI may be pleasant for the interaction of .NET code and C ++ libraries, but in addition, I did not find an opportunity for it.

There is a good overview on the Wikipedia page: http://en.wikipedia.org/wiki/C%2B%2B/CLI

And yes, they are right to jump on you because you can program in C ++. CLI will not allow you to program in C ++ ... they are quite different that you cannot just mix them.

+2
source

C ++ runs directly, since binaries are executed for your hardware. C ++ cli is a C ++ extension that is used to interact with the MS common language runtime. It conforms to IL normally and runs inside .net runtime. There are numerous differences between the two main ones: garbage collection and how inheritance and interfaces work.

The reason for using C ++ Cli is the benefits of using hundreds of classes provided to you by the framework. All of them are available from any language compatible with the CLR, so some had to wonder why use C ++ to access the infrastructure if you are not contacting some kind of legacy code.

+2
source

AFAIK, C ++ CLI allows you to have access to the .net infrastructure.

It offers some garbage collection and several other functions other than C ++

+1
source

Source: https://habr.com/ru/post/1299676/


All Articles