- 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.
Item 34: Understand how to combine C++ and C in the same program.(More Effective C++)
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Item 35: Familiarize yourself with the language standard.(More Effective C++)
下一篇:Item 33: Make non-leaf classes abstract.(More Effective C++)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
《More Effective C++ 》笔记
条款10 防止构造函数里的资源泄露条款20 协助编译器实现返回值优化条款22 考虑使用op=来取代单独的op运算符条款26 限制类对象的个数条款27 要求或禁止对象分配在堆上
构造函数 类对象 编译器 运算符 javascript -
Mixing C and C++ Code in the Same Program
his article sho
c++ oracle ide ios sed