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

โˆ™ 2008-02-10 09:57:41
This answer is:
User Avatar
Study guides

Data Science

โžก๏ธ
See all cards
4.29
โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…
7 Reviews

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

Syntax of enumeration in c plus plus?

// for definition of enumerated type: enum [tag] [: type] {enum-list} [declarator]; // for declaration of variable of type tag: enum tag declarator;


What is an enumeration in c plus plus?

In C++, an enumeration (enum) is a group of constants. In C++11 an enumeration is a class of constants.


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 windows c plus plus and Linux c plus plus?

There are no such things as 'Windows C++' and 'Linux C++'


Difference between c plus plus and Vc plus plus?

VC++ is Microsoft's implementation of C++.


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.


What is the difference between class and object in c plus plus?

There is no difference; to define an object in C++ you use the 'class' definition


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

There are no such terms in C++.


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 arrays in c and c plus plus?

Nothing whatsoever. They are exactly the same.

People also asked