|
|
|
|
|
by dianeb
2675 days ago
|
|
Well, "better" is a loaded word, and you need to remember that C++ is not a superset of C. The two languages intersect in a fairly large subset of C, but there are parts of C++ that are not the same. I would claim that C++ is remarkably less safe than C because of the crazy games some people play with what's laughingly called "template meta-programming." You can abuse the C preprocessor, but not to the extent that its C++ mode permits. That aside, the comparison of programming languages to automobiles still holds: C is a Formula One race car without seatbelts. C++ now resembles Ada in terms of size to the extent that it's a large staff car that comes in only one color. Java, which originally seemed to be a sane C++, is sort of like my father's Buick -- it looks nice but when you really need to do something slightly out of the ordinary like carry skis you can't do it without an accessory. That's right, it is a proprietary language (hence C#) |
|
C++ contains a subset which is a dialect of C that is so compatible with C (in particular C90) that you can write code in it that compiles as C, and with very little effort. (Which I know from extensive personal experience, not just theory).
(Such code benefits from the extra checks and diagnostics C++ provide; and with some #ifdef switching and macros, it can take advantage of some additional C++ diagnostic fatures when being compiled as C++.)
Quotes from Bjarne Stroustrup's C++ FAQ:
"Well written C tends to be legal C++ also."
"It is not uncommon to be able to convert tens of thousands of lines of ANSI C to C-style C++ in a few hours. "