answersLogoWhite

0


Best Answer
Copy

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:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Add your answer:

Earn +5 pts
Q: What is difference between C enum and C plus plus enum?
Write your answer...
Submit

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;


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 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.


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++.


Difference between enum and const in c?

An enum has a set of named constants, eg.enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};int x = (int) Days.Sun;x will output 2and a constant is a variable whose value can't be changed.


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 meant by enum in C programming?

The enum keyword means enumeration.


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

Well, C and C++ are programming languages, while C-- is not.


Difference between dynamic binding and message passing in c plus plus?

what is the difference between message passing and dynamic binding


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

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


What is difference between c plus plus and net?

C++ is a language. .NET is an environment. They are not really comparable.


Write a simple program in C plus plus to investigate the safety of its enumeration types?

If you want safety in enums, use an enum class rather than an ordinary enum. Ordinary enums can be implicitly converted to their underlying type whereas enum classes cannot. Enum classes are also scoped to their class, which avoids name-clashes when two enumerations have the same member.


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 ANSI C and C plus plus?

C and C++ are different programming languages, ANSI C is a standardized version of C.


What is the difference between Prolog and C plus plus languaqge?

Everything. Actually, there is no similarity between the two.


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

There is no difference. Both statements are invalid.


Defference between c plus plus and c?

these are difference in between c and c++: a) C is a SPL and C++ is a OOP. b) C has not concept of object but C++ has this feature. c) C has not 'class' name data type but C++ has.


Difference between java and C plus plus?

java is an advanced object oriented programming language than c++