Item 34: Understand how to combine C++ and C in the same program.(More Effective C++)
- Make sure the C++ and C compilers produce compatible object files.
- Declare functions to be used by both languages
extern"C". - If at all possible, write
mainin C++. - Always use
deletewith memory fromnew; always usefreewith memory frommalloc. - Limit what you pass between the two languages to data structures that compile under C; the C++ version of structs may contain non-virtual member functions.
浙公网安备 33010602011771号