answersLogoWhite

0


Best Answer

In C++, enum signifies a slightly stronger type than in C.

For example, in C, one could write:

enum Direction { UP, DOWN };

Direction d = 1;

In C++, this would be illegal, only UP or DOWN can be assigned to a variable of type Direction, though there is still implicit casting to integer, so one could still write:

int i = UP;

Another difference has to do with the way variable are declared in general in C++. In C, once the enum was declared as above, declaring variables of type Direction would have to be done through the enum keyword, like this:

enum Direction d = UP;

In C++, the name "Direction" becomes a type in itself, so you can write:

Direction d = UP;

User Avatar

Wiki User

16y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is difference between C enum and C plus plus enum?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

In c plus plus you cannot assign integer value to enum?

That is correct - In c plus plus you cannot assign integer value to enum - You can only assign an enum value to an enum. Even though an enum looks like an integer, it is not. It is an enum, and C++ implements strict type checking to reduce the probability of bad programming practices. enum ColorCode {black, brown, red, orange, yellow, green, blue, violet, grey, white}; ColorCode myColorCode; myColorCode = yellow; Even though yellow has an integer value of 4, you cannot say myColorCode = 4.


What is the difference between pointers in c and c plus plus?

Nothing.


Difference between void and devoid in c plus plus?

There is no such thing as devoid in C++.


What is meant by enum in C programming?

The enum keyword means enumeration.


How do you pass enum object as argument to function in c?

You can't pass an enum as an argument to a function. An enum in C isn't an object, it's a type. All you can do is pass a variable that is of the particular enum's type.


What is the difference between be plus ing and get plus ing?

There are no such terms in C++.


What is the Difference between arrays in c and c plus plus?

Nothing whatsoever. They are exactly the same.


Is there any difference between turbo c and c plus plus?

turbo c is a compiler and c++ is a programming language.


What is the difference between cc plus plus and c sharp?

C# is inherited from c++ with some additional features


What is the difference between c plus plus and java programming?

Java doesn't have pointers. C++ has pointers.


What are the main differences between Java and C plus plus?

the difference is that c plus is better because you get big grades


What is the difference between statements in c plus plus charconstp and char constp?

There is no difference. Both statements are invalid.