Lecture 1 - Slide 34 : 34
C/C++ Compatibility - some small details
Most of details mentioned below do not appear in everyday C programs
The C++ Prog. Lang. (3. edition)
:
Page 816
The C++ Prog. Lang. (4. edition)
: Page 1271
Comments
//
comments are supported in C++ and C99, but not in ANSI C (C89)
Functions without argument types
Legal in C - but poor style in C. Not legal i C++.
A type is
int
if not specified
Possible in C, but poor style. Not legal i C++
'Inline' structs in return type and in parameter lists
Possible in C. Not legal i C++.
Enumeration types
In C a variable of enumeration type can be assigned to an integer.
Not possible in C++.
Multiple definitions at global level
Global data definitions may be repeated in C. Not in C++.
Pointers to void
may in C be assigned to variables of any pointer type. Not in C++.
Static
In the meaning of 'local to translation unit' is deprecated in C++.
Casts
C-style casts should have been decrepated...
C++ has other means for casting.
Examples appear in appendix B.2 in
The C++ Prog. Lang. (3. edition)