On Windows, unless we have to use C + + to write the interface, I would choose to avoid, avoid learning and use MFC. The alternative is to use C # for the interface, and then to connect C # and native C + + in CLI. So the question is, C + +/CLI is sacred?
That's what Baidu says about C + +/CLI-"C + +/CLI is a bundle of static C + + object models to the CLI's dynamic Component Object programming model." In short, how to use C + + in NET, instead of C # or Visual Basic. Like C # and the CLI itself, C + +/CLI is being standardized under the auspices of the ECMA (European Computer Manufacturers Association) to eventually meet the ISO standard. The common language runtime (CLR) is the Microsoft version of the CLI, which works well for Microsoft's Windows operating system, and similarly, Visual c++2005 is a C + +/CLI implementation. ”
That's what I said.--c++/cli is equivalent to C # and native C + + 's combined language, in most cases you can write code managed code like C #, or write native code like native C + +, or include both languages in the same file. The compiler makes a good distinction between the two.
That's what Daniel says ——. Net. net,c++ to C + +. Here net refers to managed code, C + + refers to local code.
Let's have some details:
1. From the project type of VS, there are three kinds: one is native code and does not use CLR support. This project is still the original C + + project, without any changes, directly compiled native code. Can be referenced by a C + +/CLI project, but cannot be referenced by other managed language projects. The second is the original native code, which is added to the CLR support at compile time and becomes capable of being used by others. NET language, such as C #, to invoke a project or DLL. This project itself does not contain managed code, but can be referenced by other managed code (including C + +, C #, etc.). The third is a CLR project, which is a native managed project in which, in addition to the default managed code, you can use #pragma unmanaged to instruct the code to compile the cost machine code. You can call other managed code or native code directly, or it can be called by other managed code.
2. From memory, the memory of C + +/CLI is divided into 3 kinds: stack memory, native heap memory and managed heap memory. The stack memory can contain native objects and managed objects, exiting the range where their life cycle ends without distinction. Native heap memory is native C + + dynamic memory that can be dynamically and dynamically allocated via the new or malloc keyword. After use, manually released by the programmer, otherwise memory leaks. Managed heap memory is the dynamic memory of managed objects and is dynamically allocated by the GCNEW keyword. Managed object memory that is no longer used is reclaimed by the public runtime garbage collector (. Net GC) and is not handled by the programmer.
3. From the class library, the CLR project native supports all types in the. Net framework that satisfy the CLS. such as the common C # string, list, dictionary, and so on, where the use of basic unchanged.
Here is a brief introduction, the follow-up will have more detailed content ...
VC + + Study notes (iii): The Modern road--C++/CLI introduction