What is the difference between enum struct and enum class?

Rakete1111

Looking at the enum documentation, there was one thing that I noticed:

enum-key - one of enum, enum class(since C++11), or enum struct(since C++11)

enum and enum class, sure, but what is a enum struct?

The docs seem to say that enum class and enum struct are exactly the same:

[...] scoped enumeration (declared with the enum-key enum class or enum struct)


  • enum struct|class name { enumerator = constexpr , enumerator = constexpr , ... }
  • [...]

Are they really exactly the same? Or are there any differences that I missed? What is the point (if they are the same) to have 2 different syntax for the same thing?

AlexD

enum class and enum struct are the same (emphasis mine).

7.2 Enumeration declarations
...
2 .... The enum-keys enum class and enum struct are semantically equivalent; an enumeration type declared with one of these is a scoped enumeration, and its enumerators are scoped enumerators.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What is the difference between Enum and MaterialEnum?

From Dev

Difference between static enum and static struct

From Java

What is the difference between `Enum.name()` and `Enum.toString()`?

From Dev

What is the difference between array and enum in C ?

From Dev

Difference between enum and Enumeration

From Java

What's the difference between struct and class in .NET?

From Dev

Replace enum with struct inside a class

From Dev

Difference between java enum with no values and utility class with private constructor

From Dev

What is the difference between NS_ENUM and NS_OPTIONS?

From Dev

What's the difference between these two enum declarations in swift?

From Dev

What's the Difference between EndEllipsis and WordEllipsis in TextFormatFlags enum?

From Dev

What's the difference between these two enum declarations in swift?

From Dev

What's the Difference between EndEllipsis and WordEllipsis in TextFormatFlags enum?

From Dev

Difference between Enum and IntEnum in Python

From Dev

difference between "enum" and "in" in model description

From Dev

What is the pros and cons between Enum and enum-based class implementation in Java?

From Dev

What is the pros and cons between Enum and enum-based class implementation in Java?

From Dev

Performance between `(Enum)(object)e` and `e as Enum` where e is struct

From Dev

According to memory allocation in program what is different between enum ,struct,union , classes, Interface and its relation between them

From Dev

What are the allowed types for an enum (class)?

From Dev

Dynamic initialization of enum class inside template struct

From Dev

Struct , class or enum for service object with static methods?

From Dev

What is a struct variant enum in std:serialize?

From Dev

What's the difference between Struct based and Class based singletons?

From Dev

How should I reason when I have to choose between a class, struct and enum in Swift?

From Dev

Whats the difference between Enum, Structs, Classes

From Dev

What is the difference between struct and dict?

From Dev

What is the difference between struct addrinfo and struct sockaddr

From Dev

What is the difference between Vec<struct> and &[struct]?

Related Related

  1. 1

    What is the difference between Enum and MaterialEnum?

  2. 2

    Difference between static enum and static struct

  3. 3

    What is the difference between `Enum.name()` and `Enum.toString()`?

  4. 4

    What is the difference between array and enum in C ?

  5. 5

    Difference between enum and Enumeration

  6. 6

    What's the difference between struct and class in .NET?

  7. 7

    Replace enum with struct inside a class

  8. 8

    Difference between java enum with no values and utility class with private constructor

  9. 9

    What is the difference between NS_ENUM and NS_OPTIONS?

  10. 10

    What's the difference between these two enum declarations in swift?

  11. 11

    What's the Difference between EndEllipsis and WordEllipsis in TextFormatFlags enum?

  12. 12

    What's the difference between these two enum declarations in swift?

  13. 13

    What's the Difference between EndEllipsis and WordEllipsis in TextFormatFlags enum?

  14. 14

    Difference between Enum and IntEnum in Python

  15. 15

    difference between "enum" and "in" in model description

  16. 16

    What is the pros and cons between Enum and enum-based class implementation in Java?

  17. 17

    What is the pros and cons between Enum and enum-based class implementation in Java?

  18. 18

    Performance between `(Enum)(object)e` and `e as Enum` where e is struct

  19. 19

    According to memory allocation in program what is different between enum ,struct,union , classes, Interface and its relation between them

  20. 20

    What are the allowed types for an enum (class)?

  21. 21

    Dynamic initialization of enum class inside template struct

  22. 22

    Struct , class or enum for service object with static methods?

  23. 23

    What is a struct variant enum in std:serialize?

  24. 24

    What's the difference between Struct based and Class based singletons?

  25. 25

    How should I reason when I have to choose between a class, struct and enum in Swift?

  26. 26

    Whats the difference between Enum, Structs, Classes

  27. 27

    What is the difference between struct and dict?

  28. 28

    What is the difference between struct addrinfo and struct sockaddr

  29. 29

    What is the difference between Vec<struct> and &[struct]?

HotTag

Archive