* Ioannis Vranos:
> Ian Collins wrote:
>> Ioannis Vranos wrote:
>>> Carmen Sei wrote:
>>>> if I need to write C++, I will be forced to learn C automatically?
>>>>
>>>> Since I saw many C++ code need to call C library also.
>>>>
>>>> Most program use a combination of C++ code and calling C functions.
>>>>
>>>> Then writting C++, I cannot avoid learning C right?
>>> With minor exceptions C95 (ISO/IEC 9899:1995) is a subset of C++
>>> (ISO/IEC 14882:2003).
>> No, they are not "minor exceptions".
>
>
> Supposing you are not talking about the word "exception", the exceptions
> I know are the following:
>
>
> 1. Not implicit void * to any other pointer type conversion, as in C95.
> 2. 'a' is a char in C++ and not an int as in C95.
> 3. 0 is to be preferred than NULL, which does not apply to C95.
> 4. POD types can be considered as char/unsigned char sequences in C++,
> but only as unsigned char sequences in C95.
> 5. Empty parentheses in function declarations/definitions are equivalent
> to void in C++, but is a different thing in C95.
>
>
> (6?) The following is guaranteed to not compile in C95, but it compiles
> in my C++ compiler, but I am not sure if it is a difference or a
> compiler-thing:
>
>
> int main(void)
> {
> register char array[]= "Test";
>
> char *p= array;
>
> return 0;
> }
>
>
> Have I forgotten anything?
The C++ standard enumerates the C89 compatibility issues.
§C1.1/1 "//"-comments (no such in C89) Forgotten.
§C1.1/2 new keywords, e.g. "class", "new", "delete". Forgotten.
§C1.1/3 Char literal as type "char". Listed, (2).
§C1.1/4 String literals made const. Forgotten.
§C1.2/1 No tentative definitions like "int x; int x;" Forgotten.
§C1.2/2 "struct" is scope Forgotten.
§C1.2/3 Default internal linkage of filescope "const" Forgotten.
§C1.2/4 "main" non-recursive and without address. Forgotten.
§C1.2/5 No "compatible" types like in C. Forgotten.
§C1.2/6 void* to other type requires casting. Listed, (1).
§C1.2/7 Only non-const non-valid conversion to void*. Forgotten.
The list continues. Above covers differences in sections 1 through 5 of the
standard. I think you get idea... :-)
Cheers, & hth.,
- Alf
PS: Oh, in practice the next point is perhaps one of the most likely to surface
when trying to compile C as C++, namely §C1.3/1 implicit declarations not
allowed in C++.