By using this site, you agree to our Privacy Policy and our Terms of Use. Close
radha said:
NJ5 said:

I said essentially a subset. There are very few things which work in C but not C++, and they're all small details which can be converted in one second. Those differences are not relevant for this thread, they're slight nitpicks as you can read here:

http://www.research.att.com/~bs/bs_faq.html#C-is-subset

Thus, C++ is as much a superset of ANSI C as ANSI C is a superset of K&R C and much as ISO C++ is a superset of C++ as it existed in 1985. Well written C tends to be legal C++ also.

You mentioned structures. C's structures are also supported in C++, in fact a class is just a souped-up structure which allows to use the public/private/protected keywords.

You mentioned speed. C++ is not slower than C with equal code, only if you use a slower C++ feature (which you aren't forced to).

 

Thats not all, C++ has a more strick type check and some types on C wont compile on C++. and when i say speed i mean at low level of course, since thats mostly the main use of C now days. 

 

More strict type checking, yes. But those things are very quick to solve and mostly occur on poorly-written code, which is why almost everyone says C is essentially a subset of C++. I hope we agree on that because it not only makes sense, but it's the generally held opinion (the quote I posted is from the guy who invented C++).

The fact stands that whoever knows C++, knows C.

I know what you meant by speed. But a good C++ compiler will compile well written C code to be as fast as generated by a C compiler. There's no reason for C++ to be necessarily slower than C other than a lower-quality compiler or using non-C features.

 



My Mario Kart Wii friend code: 2707-1866-0957