6 ms·
I never heard anyone say that C++ is a superset of C. Sure, the first version was a preprocessor on top of C and certainly that is common knowledge. But a supe
by jdmoreira 7y ago
I never heard anyone say that C++ is a superset of C.
Sure, the first version was a preprocessor on top of C and certainly that is common knowledge. But a superset? Never heard it.
ObjC on the other hand...
- dahfizz 7y agoI've definitely heard c++ described this way.
- Animats 7y agoIt was a superset, once. C++ started as a C preprocessor. But the languages have diverged. It's enough of a superset, though, that C++ hasn't deleted bad features of C, like pointers and arrays being the same thing.
- loeg 7y agoIt was maybe a superset for the brief period between C++98 standardization and C99 standardization the following year.
- _kst_ 7y agoPointers and arrays are not the same thing. See section 6 of the comp.lang.c FAQ, http://www.c-faq.com/ http://www.c-faq.com/ . I doubt that C++ was ever a strict superset of C. Has int class; ever been a valid declaration in C++?
- eesmith 7y agoOnce C++ gained "//" for comments - which was the original release in 1983 - it was no longer a superset: uses_BCPL_style_comments = 1 //* */ 2 ; C99's // support did not restore the superset nature. This means your "once" was almost certainly "never".
- MauranKilom 7y agoYou evidently haven't been looking at the stackoverflow questions coming in at the [c] and [c++] tags... ;) A frightening amount of [c][c++] tagging is expunged there every day.
- EpicEng 7y agoAnd 90% of those posts are made by beginners with a crashing linked list implementation. They're uninformed.
- Veedrac 7y agoWhich is often just meaningless pedanticism. There are a lot of questions about C APIs where it's irrelevant whether the answer uses C or C++. The latter might not be an exact superset, but in most cases it's easily close enough.
- lochsh 7y agoI think it's quite a common thing for people to say if they're not actually experienced in writing the languages. I've heard it from multiple people. As I say in the blog post, it's common knowledge for people who are experienced in writing C and/or C++ that this isn't true. But it's a misconception that persists among other programmers.
- Laakeri 7y agoHave you seen practical cases where there has been issues because C code is not compatible with C++? The blog has nice toy examples, but would be nice to know if they actually occur in the wild.
- loeg 7y agoYes, all the time. Off the top of my head, I've run into: - C++ does not support 'foo([static N])' function declarations - C++ does not support 'struct A a = { .b = c, ... }' initializers The conflict arises when these are used in C headers, and then C++ programs attempt to include them.
- dec0dedab0de 7y agoI thought it was until just now. I've never done anything of substance in either, but I've tried both. Now I'm wondering if it was something I heard, or if I just assumed based on my extremely limited experience with both languages.
- eesmith 7y agoFWIW, https://duckduckgo.com/?q=%22C%2B%2B+is+a+superset+of+C%22&t=ffsb&ia=web https://duckduckgo.com/?q=%22C%2B%2B+is+a+superset+of+C%22&t... finds things like: - C++ is a superset of C, and that virtually any legal C program is a legal C++ program. https://www.tutorialspoint.com/cplusplus/cpp_overview.htm https://www.tutorialspoint.com/cplusplus/cpp_overview.htm - "C is a subset of C++." / "C++ is a superset of C." https://www.geeksforgeeks.org/difference-between-c-and-c/ https://www.geeksforgeeks.org/difference-between-c-and-c/ - "C++ is a superset of C; (almost) anything you can do in C, you can do in C++." https://www.cprogramming.com/begin.html https://www.cprogramming.com/begin.html - "As you recall C is a root for C++ and C++ is a superset of C." https://www.c-sharpcorner.com/article/similarities-and-difference-with-C-Sharp-and-other-languages/ https://www.c-sharpcorner.com/article/similarities-and-diffe...