如何使用纯c来编写OO程序 [英] how to use pure c to write OO programs

查看:103
本文介绍了如何使用纯c来编写OO程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人会说如何使用纯c来编写OO程序吗?


感谢先进!

can some one tell that how to use pure c to write OO programs?

thanks in advanced!

推荐答案

2005年10月19日03:49:10 -0700, zh ****** **@gmail.com 写道:
On 19 Oct 2005 03:49:10 -0700, zh********@gmail.com wrote:
有人可以告诉我们如何使用纯c来编写OO程序吗?

感谢先进!
can some one tell that how to use pure c to write OO programs?

thanks in advanced!



我不认为纯粹是正确的形容词。


使用结构,指向结构的指针,指向函数的指针,枚举。


不要使用联合。


练习很多。


祝你好运!


I don′t think "pure" is the right adjective.

Use structs, pointers to structs, pointer to functions, enums.

Do not use unions.

Practise a lot.

Good Luck!


下面这篇文章给出一个面向对象编程的例子

in C:

http://www.eventhelix.com/RealtimeMa...mming_in_c.htm


-

EventStudio系统设计器2.5 - http://www.EventHelix.com/EventStudio

基于序列图的实时和嵌入式系统设计工具

The following article gives an example of object oriented programming
in C:

http://www.eventhelix.com/RealtimeMa...mming_in_c.htm

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based Real-time and Embedded System Design Tool


zh ******** @ gmail.com 写道:
可以有人告诉如何用纯c来写OO计划?
can some one tell that how to use pure c to write OO programs?



1.面对墙壁。

2.退后几步。

3.低着头,跑到墙上。

4.重复直到你觉得自己对自己造成了足够的伤害。


我意识到这不是真的有用。然而,当谈到

OO编程时,两者都不是纯粹的。


在我看来,使用C ++前端会好得多,

限制自己使用基本的OO概念,同时忽略C ++铃声

和口哨对你的设计不重要。我不知道

仍然存在任何前端(如果我想要C ++,我知道在哪里获得它b / b)。任何人都知道cfront或者克隆是否仍然存在,并且有用吗?


你甚至可以发疯并使用一个真正的C ++编译器。很多

产生了相当可接受的代码(在大小/速度/开销方面)

简单的C ++并没有引入所有的STL好东西。实际上,对于C ++来说,无论好坏,初步设计标准都包含了编译器不应该负担得太多的概念

有效(在语言

定稿时,这个概念还剩下多少,但这是另一个问题)。


Of当然,如果你没有为

平台提供C ++编译器,或者如果目标文件与C代码兼容,那么这对你不会有帮助,但

it还是值得考虑的。


S.


1. Face a wall.
2. Take quite a few steps back.
3. Holding your head down, run towards the wall.
4. Repeat until you feel you have inflicted enough harm on yourself.

I realize this is not really helpful. Neither is pure C when it comes to
O-O programming, however.

In my opinion, you''d be much better off using a C++ frontend,
restricting yourself to basic O-O concepts while ignoring the C++ bells
and whistles that are not essential to your design. I don''t know about
any frontends still out there, though ("if I want C++, I know where to
get it"). Anyone know if cfront or a clone still lives, and is of any use?

You could even go crazy and use, you know, an actual C++ compiler. Many
produce quite acceptable code (in terms of size/speed/overhead) for
simple C++ that doesn''t pull in all the STL goodies. In fact, the
initial design criteria for C++, for better or worse, included the
notion that compilers shouldn''t be too burdened processing it
effectively (not much was left of this notion by the time the language
was finalized, but that''s another issue).

Of course this won''t help you if you don''t have a C++ compiler for the
platform or if object file compatibility with C code is necessary, but
it''s still worth considering.

S.


这篇关于如何使用纯c来编写OO程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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