mercredi 19 avril 2017

enum class of type string in C++

There is a class in C++11 known as enum class which you can store variables inside. However, I have only seen the type of the class to be char:

enum class : char {
   v1 = 'x', v2 = 'y'
};

Question:

Is there any way I can express this enum class of type string ?

For example,

enum class: string{
  v1 = "x", v2 = "y"
};

The reason is that strings are capable of holding multiple characters at the same time, so it makes it easier to use in the code.

Aucun commentaire:

Enregistrer un commentaire