dpoh61610 2009-02-16 07:55 采纳率: 100%
浏览 57
已采纳

为什么有些程序是用C ++编写的,而其他程序则不是?

That's something I've been wondering for a while now.

Take Notepad++ for instace. Wikipedia tells me it was written in C++ and it's Windows-only.

Now take PHP. Wikipedia tells me this is also written in C++, but that runs on other OS too.

But I see more languages then just C++ for PHP... how is this done? Do they make some new code in C++, see it works and then figure out how to do it in Perl, or what happens?

  • 写回答

8条回答 默认 最新

  • douqiang6448 2009-02-16 08:03
    关注

    It depends whether you are using platform specific libraries or not. Notepad++ is a desktop application and it needs a GUI toolkit. Although there are cross-platform C++ libraries like Qt and wxWidgets, Notepad++ is probably using a Microsoft's specific technology. Thus it can't be ported in other platforms.

    PHP on the other side is a WEB scripting technology so there's no need of GUI library. Also there is much more stronger interest in running PHP in many platforms than there is for Notepad++. That is an incentive for the developers to make the C++ code cross platform.

    Avoid platform specific libraries isn't the only thing needed for a C++ cross platform application. It usually means coding for the least common denominator and keeping different code branches for every platform supported. Although C++ is a cross platform language, each system has its own intricacies. In fact the code could be different in the same platform as well, if a different compiler was to be used. Try downloading the C++ source of an open source application, like PHP for example. You would notice that much of the code is the same for all platforms, but there would be different bits also. Sometimes preprocessor directives are used, elsewhere totally different source files are involved.

    So creating a true cross-platform C++ application is a hard job and it is usually created when there is a strong incentive to do so and many people are involved. An one-man application like Notepad++ really can't be cross-platform.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?