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].

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值