| ▲ | AdieuToLogic 9 hours ago | ||||||||||||||||
From the article:
C++ was a superset of C 30-ish years ago. Now, as the author correctly identifies, it is not as both have taken different evolutionary paths. | |||||||||||||||||
| ▲ | electroly 8 hours ago | parent | next [-] | ||||||||||||||||
30 years ago, in C89 and pre-standard C++, it was the case that `int foo()` in C is a function that accepts any parameters, and in C++ it is a function with no parameters. In C89 you have to write `int foo(void)` if you want no parameters. This counterexample to C++ being a superset of C was well-known even back then. Another well-known counterexample is implicit conversion from void*. In C89 you can do `int* foo = malloc(100);` but in C++ it requires an explicit cast from void* to int*. I don't believe there was ever a time, even pre-standardization, when C++ was a strict superset of C; it always had little incompatibilities here and there. | |||||||||||||||||
| |||||||||||||||||
| ▲ | pjmlp 9 hours ago | parent | prev [-] | ||||||||||||||||
Already in C++98 there were differences. ?: has another execution priority. Implicit cast scenarios are reduced in C++. | |||||||||||||||||