1) when the obj-C compiler processes files with a suffix of m, it can recognize the code of obj-C and C. When processing mm files, it can recognize obj-C, C, c ++ code, but the CPP file must only use C/C ++ code, and the obj-C code cannot appear in the header file of the CPP File Include, because CPP is only CPP
2) Mix CPP in the MM file and use it directly. Therefore, obj-C Mixed CPP is not a problem.
3) Mixing obj-C in CPP is actually what we want to write modules using obj-C.
If the module is implemented as a class, write the class definition according to the CPP class standard. The header file cannot contain obj-C, including # import cocoa. In the implementation file, that is, the implementation code of the class can use obj-C and can be imported, but the suffix is mm.
If the module is implemented by functions, the header file should declare the function in the C format. In the implementation file, the C ++ function can use obj-C internally, but the suffix is still mm or M.
Summary: as long as the CPP file and the CPP include file do not contain obj-C, you can use it. The key to mixing CPP with obj-C is to use interfaces, instead, you cannot directly use the implementation code. In fact, CPP is a mix of the O files compiled by obj-C. This is actually the same, so it can be used. The combination of obj-C and CPP is simple. You can use it directly, because the obj-C compiler supports it.