I came from Java and here we have such option as set value to constuctor.
Example
enum TYPE
{
AUTO(\"BMW\"),
MOTOCYCLE(\"Kawasaki\");
pr
In C++ a class has to be created:
class TYPE
{
public:
static const TYPE AUTO;
static const TYPE MOTOCYCLE;
private:
std::string mBrandName;
TYPE(std::string iBrandName)
: mBrandName(iBrandName)
{}
TYPE(const TYPE&) = default;
TYPE(TYPE&&) = default;
TYPE& operator=(const TYPE&) = default;
TYPE& operator=(TYPE&&) = default;
~TYPE() = default;
public:
std::string getBrandName() { return mBrandName; }
static TYPE getMotocycle() { return MOTOCYCLE; }
static TYPE getAuto() { return AUTO; }
};
const TYPE TYPE::AUTO("BMW");
const TYPE TYPE::MOTOCYCLE("Kawasaki");
But this doesn't have the benefits of an enum (automatic numbering, ordering, conversions,...)