C语言 面向对象编程

C语言是典型的“面向过程式语言”,与之相对应的C++是“面向对象的编程语言”。但是很多人不知道的是C语言也可以实现面向对象的编程。从根本上说任何图灵完备的语言都可以互相实现。这么说你想用汇编实现面向对象理论上也是可以的。另外,高级语言不都是先编译成汇编,再形成机器码么。。。

面向对象编程(OOP)不是使用特定的语言或工具。它是一种基于三个基本设计元模式的设计方法:
封装:数据和函数在一起打包成类的能力
继承:基于现有类定义新类的能力,以便获得重用和代码组织
多态:能够在运行时相互替换匹配接口的对象
尽管这些元模式传统上与面向对象的语言(如asSmalltalk、c++或Java)相关联,但是您几乎可以用任何编程语言实现它们,包括可移植的ANSI-C。

原文:QP平台(https://www.state-machine.com/)《AN_OOP_in_C》Object-Oriented Programming in C
下载:https://www.state-machine.com/doc/AN_OOP_in_C.pdf

Object-oriented programming (OOP) is not the use of a particular language or a tool. It is rather a way ofdesign based on the three fundamental design meta-patterns:

• Encapsulation – the ability to package data and functions together into classes
• Inheritance – the ability to define new classes based on existing classes in order to obtain reuse andcode organization
• Polymorphism – the ability to substitute objects of matching interfaces for one another at run-time

Although these meta-patterns have been traditionally associated with object-oriented languages, such asSmalltalk, C++, or Java, you can implement them in almost any programming language including portable ANSI-C [1,2,3,4,5,6].

猜你喜欢

转载自blog.csdn.net/weixin_44005390/article/details/90205076