I am trying to use `enum class`, but finding difficulties converting from other types that have logical correspondence to the enumeration. Here's an example:

```
enum class ElementType {
    unknown,
    signedInt
};

struct VectorType {
    int vectorSize;
    ElementType elementType;
    int elementSize;
}

```

I want to be able to initialize a `VectorType` by saying

```
VectorType vt {4, 's', 32};

```

So I tried defining a cast operation from char to the enum like so:

```
operator ElementType(char c) {
    switch (c) {
    case 's': return ElementType::signedInt;
    default : return ElementType::unknown;
    }
}

```

But that didn't work, as it gives the following error:

```
error: ‘operator ElementType(char)’ must be a nonstatic member function

```

So the only solution I can come up with is create a separate constructor:

```
VectorType(int vsz, char etp, int esz) {
    vectorSize = vsz;
    elementType = make_elementType(etp);
    elementSize = esz;
}

```

and have the global non-member make\_elementType() function deal with the conversion. Is there a way to avoid this, i.e. is there a way to use `VectorType vt {4, 's', 32};` to initialize a `VectorType`?

Thanks