3 ms·
The C++ specification has an entire appendix devoting to listing incompatibilities with C. Some features missing from this list: * A char literal is an express
by jcranmer 7y ago
The C++ specification has an entire appendix devoting to listing incompatibilities with C. Some features missing from this list:
* A char literal is an expression of type int in C, but type char in C++.
* String literals are const in C++ but non-const in C (although attempts to modify them are undefined behavior).
* This program is legal C but not C++:
int i;
int i;
* structs and unions occupy a different name space in C than they do in C++.
* main cannot be recursive in C++, but it can in C.
* C++ allows lvalues in a few more places. Usually, this amounts to a compiler error, but there are a few places where the additional lvalue-to-rvalue conversion is legal and produces a different result.
* There are some cases where C++ requires an explicit cast that C permits an implicit cast (void* being the most well-known)
- deleted 7y ago[deleted]