Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: All
Apr 9, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Subtle Differences Between C and C++

There are a few semantic differences between C and C++ in the way they interpret certain language constructs. These differences may not result in a compiler diagnostic, so it is important to pay attention to them when porting code from C to C++ and vice versa. For example, in C, the size of an enumeration equals the sizeof of an int, whereas in C++, the size of an enumeration doesn't have to be an int. Also, in C, the result of applying the operator sizeof to a character constant, for example, sizeof('c'); equals sizeof(int). In C++, on the other hand, the expression sizeof('c'); returns sizeof(char).
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date