第27章 C语言
1. C与C++
2. C与C++的兼容性
3. C不支持的C++特性
4. C中函数与C++的区别:不支持函数重载
5. 函数参数检查
6. 函数定义
7. 在C++中调用C和在C中调用C++
![读书笔记之:C++程序设计原理与实践(ch27:C与C++的区别)[+++]_c++_17](https://s2.51cto.com/images/blog/202108/11/074908ec6ce9d17175c9915e00a414a8.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=/resize,m_fixed,w_1184)
![读书笔记之:C++程序设计原理与实践(ch27:C与C++的区别)[+++]_字符串_18](https://s2.51cto.com/images/blog/202108/11/db9cd2cdc3edadaaf928ed14cafc1dcc.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=/resize,m_fixed,w_1184)
8. 函数指针
![读书笔记之:C++程序设计原理与实践(ch27:C与C++的区别)[+++]_C与C++区别_21](https://s2.51cto.com/images/blog/202108/11/c1552fee544de118f0073446c7155126.gif)
View Code //
// This is example code from Chapter 27.2.4 "Pointers to functions" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//
*/
/*----------------------------------------------------------------------------*/
struct Shape1 {
enum Kind { circle, rectangle } kind;
/* ... */
};
/*----------------------------------------------------------------------------*/
void draw(struct Shape1* p)
{
switch (p->kind) {
case circle:
/* draw as circle */
break;
case rectangle:
/* draw as rectangle */
break;
}
}
/*----------------------------------------------------------------------------*/
int f(struct Shape1* pp)
{
draw(pp);
/* ... */
}
/*----------------------------------------------------------------------------*/
typedef void (*Pfct0)(struct Shape2*);
typedef void (*Pfct1int)(struct Shape2*,int);
/*----------------------------------------------------------------------------*/
struct Shape2 {
Pfct0 draw;
Pfct1int rotate;
/* ... */
};
/*----------------------------------------------------------------------------*/
void draw1(struct Shape2* p)
{
(p->draw)(p);
}
/*----------------------------------------------------------------------------*/
void rotate(struct Shape2* p)
{
(p->rotate)(p,90);
}
/*----------------------------------------------------------------------------*/
int f1(struct Shape * pp)
{
draw(pp);
/* ... */
}
/*----------------------------------------------------------------------------*/
9. C/C++结构签名字空间的差别![读书笔记之:C++程序设计原理与实践(ch27:C与C++的区别)[+++]_函数重载_23](https://s2.51cto.com/images/blog/202108/11/d89b23c66989226e6f10c3bc06cd30b1.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=/resize,m_fixed,w_1184)
10. C/C++在关键字上的差别
11. C/C++在变量定义上的区别
12. C风格类型转换
13. void* 转换
14. 枚举
15. 名字空间
16. 动态内存分配
17. C风格字符串
18. C风格字符串与const
19. 字节操作
20. 实例:strcpy
21. 风格问题
22. 输入输出
23. 文件
24. 常量与宏
25. 宏
26. 类函数的宏
27. 不要使用语法宏
28. 条件编译
















