Question

This question already has an answer here:

If I just include existing Standard C++ class in C++/CLI program, will it work?

In my tests everything worked pretty good, but is it true for every program?

Was it helpful?

Solution

That is what Microsoft promises, yes. (I watched this video yesterday, in which they explicitly mentioned this -- specifically because the addition of nullptr in C++0x would compromise it)

So yeah, if you take a native C++ program and compile it as C++/CLI, with no code changes, then yes, it will still work.

And of course, if you change your code (gcnew instead of new and other "managed" changes, then of course, all bets are off, and you might or might not break the code)

OTHER TIPS

If you actually change the class to be a managed (gc) class, then no, it will sometimes break. In particular, the semantics of the delete operator is changed, as the objects are now managed by the garbage collector; deleting an object might not release any memory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top