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
main
in C++. - Always use
delete
with memory fromnew
; always usefree
with 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.