Ray's playground

 

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 from new; always use free with memory from malloc
  • 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. 

posted on 2012-03-26 12:04  Ray Z  阅读(231)  评论(0)    收藏  举报

导航