A Tip : Compiling C with C++
For instance with enums, both C and C++ allow you to use the enum values as if they were int. This will compile in C, but in C++ it gives a cannot convert from main::trafficlights to main::color error.
int main(int argc, char * argv[])
{
enum color {red,orange,yellow,green,blue,indigo,violet};
enum trafficlights {tred,tyellow,tgreen};
enum color g= red;
enum trafficlights s = tred;
g = tred;
return 0;
}
C++ doesn't allow conversion from one enumeration type to another.
- Link to C Tutorials
- Link to C++ Tutorials


No comments yet. Leave a Comment