C对象化
C++有编译器帮助,对象通过this体现;
C语言只能靠自己,一般第一个参数就是对象,例如int wake_up_process(struct task_struct *p)
面向对象的好处:
不用考虑与对象无关的状态;
有利于单元测试。
OOD:面向对象分析和建模,不过时。
特殊的对象,通过派生类解决。例如:
struct animal {
enum type;
funcBark bark;
void *extension; =>弱类型,可以强转
}
object-oriented-programming-with-ansi-c
https://ishare.iask.sina.com.cn/f/21860701.html
https://www.getfreeebooks.com/object-oriented-programming-with-ansi-c/
本文探讨了C语言中实现面向对象编程的方法,包括如何通过结构体和函数指针模拟类和对象,以及如何进行单元测试。同时介绍了面向对象设计(OOD)在C语言中的应用,以及如何使用派生类解决特殊对象的问题。

被折叠的 条评论
为什么被折叠?



