C和C ++之间的区别 [英] The difference between C and C++

查看:82
本文介绍了C和C ++之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当有人评论说代码是C

而不是C ++时,我只是在读另一篇文章。有什么区别? (例子?)答案不会影响我的编程,但会有助于知道我是否需要发布一个问题。

I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.

推荐答案

Lindsay写道:
Lindsay wrote:
当有人评论说代码是C
而不是C ++时,我只是在阅读另一篇文章。有什么区别? (例子?)答案不会影响我的编程,但有助于知道我是否需要发布问题。
I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.




简而言之,C支持只有结构化编程范例,... / b $ b C ++是一个多范式。语言,这意味着它支持

不同的编程技术,如结构化编程,

面向对象编程(感谢继承,虚函数,

强类型等等)和通用编程(感谢模板)。


几乎*任何C程序都可以用C ++编译器构建,并且

整个C标准库是C ++标准库的一部分。

另外,C ++有自己的标准库,包括STL

(标准模板库),它由通用算法和

容器组成,用于各种用途。

*参见 http://www.parashift.com/c++-faq-lit....html#faq-6.11

C标准语言/库的C ++版本基于一个稍微过时的C标准版本,但这不会影响他们的/ >
兼容性与大多数程序有关。


干杯! --M



In short, whereas C supports only the structured programming paradigm,
C++ is a "multi-paradigm" language, which means that it supports
different programming techniques such as structured programming,
object-oriented programming (thanks to inheritance, virtual functions,
strong typing, etc.), and generic programming (thanks to templates).

Almost* any C program can be built unchanged with a C++ compiler, and
the entire C standard library is part of the C++ standard library.
Additionally, C++ has its own standard library, which includes the STL
(standard template library), which consists of generic algorithms and
containers for a variety of uses.
* See http://www.parashift.com/c++-faq-lit....html#faq-6.11.
The C++ version of the C standard language/library is based on a
slightly dated version of the C standard, but this doesn''t affect their
compatibility all that much as far as most programs are concerned.

Cheers! --M


Lindsay写道:
Lindsay wrote:
当有人评论代码为C时,我正在阅读另一篇文章而不是C ++。有什么区别? (例子?)答案不会影响我的编程,但有助于知道我是否需要发帖。
I was just reading another post when someone commented that the code was C
and not C++. What are the differences? (Examples?) The answer does not
affect my programming but would help to know if I need to post a question.




C由Dennis Ritchie发明在20世纪70年代。

C ++是由Bjarne Stroustrup在20世纪80年代发明的。


C ++是作为C的继承者创建的._main_差异是支持

用于面向对象的编程,但有一些功能

的变化。这里有一些细节:

http://en.wikipedia.org/wiki/C%2B%2B


将C ++描述为C的超集是很常见的。这不是真的

true:


- 一个C程序可能使用C ++特定的保留字作为标识符

- 一些过时的语法不是C ++的一部分,比如指定函数参数类型的旧方式



- 在C99中添加的一些功能还没有成功转换为C ++

标准。


当然,C程序可以,而且通常也是一个有效的C ++程序。

但是,如果它没有使用C ++特有的任何功能,那么将它称为C ++程序是没有意义的。我的猜测是什么

无论是谁的意思是有人发布的代码片段

并没有使用任何特定于C ++的功能,因此可以是考虑

plain C,因此比comp.lang.c更适合这里。

也许如果你愿意提供一个例子,有人可以进一步澄清。 />

斯图尔特。


-

-----开始GEEK代码块-----

版本:3.1

GCS / M d- s: - C ++ @ a-> --- UB @ P + LE @ W ++ @ N +++ o K- @ w ++ @ O? M V? PS-

PE- Y? PGP-t-5? X? R b DI? DG e ++> ++++ h-- r--!y

------结束GEEK代码块------


我的电子邮件有效但不是我的主邮箱。请保持对每个人都可能受益的小组的回复。



C was invented by Dennis Ritchie in the 1970s.
C++ was invented by Bjarne Stroustrup in the 1980s.

C++ was created as a successor to C. The _main_ difference is support
for object-oriented programming, but there are a number of feature
changes. Quite some detail is gone into here:

http://en.wikipedia.org/wiki/C%2B%2B

It''s quite common to describe C++ as a superset of C; this isn''t exactly
true:

- a C program may use C++-specific reserved words as identifiers
- some obsolete syntaxes are not part of C++, such as the old way of
specifying the types of function parameters
- some features that were added in C99 have not yet made it into a C++
standard.

Of course, a C program can be, and often is, also a valid C++ program.
However, if it doesn''t use any of the features specific to C++, then
it''s rather meaningless to call it a C++ program. My guess is that what
whoever it was meant is that a snippet of code that somebody posted
doesn''t use any C++-specific features, and as such can be considered
plain C, and therefore more appropriate for comp.lang.c than here.
Maybe if you would care to supply an example, somebody can clarify further.

Stewart.

--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS-
PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox. Please keep replies on
the ''group where everyone may benefit.


是的,我想你可以通过你的代码,然后我们可以谈谈更多关于为什么

片段是C,而不是c ++

yeah, i think you can past your code, then we can talk more about why
the snippet is C , not really c++


这篇关于C和C ++之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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