面向对象用C [英] Object-orientation in C
问题描述
什么是一组漂亮的preprocessor黑客(ANSI C89 / C90 ISO兼容),这使得用C某种丑陋的(但可用的)面向对象的?
What would be a set of nifty preprocessor hacks (ANSI C89/ISO C90 compatible) which enable some kind of ugly (but usable) object-orientation in C?
我熟悉的几个不同的面向对象的语言,所以请不要用类似学习C ++!的答案回应。我已阅读面向对象编程ANSI C (请注意: PDF格式为:)和其他一些有趣的解决方案,但我在你最感兴趣的: - - !)
I am familiar with a few different object-oriented languages, so please don't respond with answers like "Learn C++!". I have read "Object-Oriented Programming With ANSI C" (beware: PDF format) and several other interesting solutions, but I'm mostly interested in yours :-)!
又见的 编写的面向对象$c$c你会写的面向对象的$ C $在C C? 的
推荐答案
C的对象系统(COS)听起来前途(它仍然在alpha版本)。它试图保持最小可用的概念简单性和灵活性的缘故:统一面向对象编程,包括公开课,元类,元类物业,仿制药,多方法,代表团,所有权,例外,合同和关闭。有描述它的论文草案(PDF)。
C Object System (COS) sounds promising (it's still in alpha version). It tries to keep minimal the available concepts for the sake of simplicity and flexibility: uniform object oriented programming including open classes, metaclasses, property metaclasses, generics, multimethods, delegation, ownership, exceptions, contracts and closures. There is a draft paper (PDF) that describes it.
的例外是的C89实现的try-catch-终于在其它OO语言中。它配备了一个测试套件和一些例子。
Exception in C is a C89 implementation of the TRY-CATCH-FINALLY found in other OO languages. It comes with a testsuite and some examples.
这两个洛朗DENIAU,这是在 OOP用C 工作了很多。
Both by Laurent Deniau, which is working a lot on OOP in C.
这篇关于面向对象用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!