在对象面向C的模式? [英] Object Oriented pattern in C?

查看:108
本文介绍了在对象面向C的模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:

  你会写面向对象code用C <? / A>

Possible Duplicate:
Can you write object oriented code in C?

我写在C大的应用程序,听说之前的C ++程序员的到来用来实现C.我的问题是什么是通常的形式这种模式需要的面向对象的格局?我怎么会去一个现代的C应用程序中实现这样的OOP模式?

I am writing a large application in C and have heard that prior to the advent of C++ programmers used to implement the "Object Oriented" pattern in C. My question is what is the usual form this pattern takes? and how would I go about implementing such an OOP pattern in a modern C application?

推荐答案

当一个C ++对象的方法,对象风格'C'需要一个结构完整的函数指针。对应于成员函数的功能有需要的隐含this指针的地方一个明确的数据参数。

Where a C++ object has methods, object-style 'C' takes a struct full of function pointers. The functions corresponding to a member function have an explicit data argument that takes the place of the implied 'this' pointer.

子类使用相同类型的函数指针结构,用不同的函数指针以指示overridded方法

Subclasses use function-pointer structs of the same type, with different function pointers to indicate overridded methods.

这篇关于在对象面向C的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆