代码设计经验的总结。让代码更加稳定,拓展性更强,一系列的编程思想。
1、什么是设计模式
建筑设计领域引入到计算机科学种来的。
一共有23种设计模式。让代码更容易被他人理解、保证代码可靠性、程序的重要性。
c语言:面向过程,一门不太友好的面向对象的语言
java:面向对象
2、什么是类和对象
类是一种用户定义的引用数据类型,也称类类型。c语言中的结构体;
对象:类的一种具象
#include <stdio.h> //类,抽象 模板 struct animal{ char name[128]; int age; int sex; int other; void (*peat)(); void (*pbeat)(); char test[32]; }; void dogeat() { printf("this is dog eat\n"); } void cateat() { printf("this is cat eat\n"); } void personeat() { printf("this is person eat\n"); } void dogbeat() { printf("yaoni\n"); } void catbeat() { printf("zhuani\n"); } void personbeat() { printf("kouni\n"); } int main() { struct animal dog={"阿黄",1,1,100,dogeat,dogbeat,"dd"};//直接赋