I had enum class, say
enum class Enum{
var1, var2;
}
Now I want to add some member which depends on parameter i.e var3(int)
. OK, It's not for enum, so I want to change it by regular class, but my goal is to leave old code(Enum::var1
as value of type Enum
) possible to compile.
I tried to do it this way(let's temporary forgot about var3
, it'll be static function):
class Enum{
public:
const static Enum var1 = Enum(1);
const static Enum var2 = Enum(2);
private:
Enum(int v):v(v){
}
int v;
//operator == using v
};
But it doesn't compile because Enum has incomplete type.
I can't declare it after class because it's in header so it'll not work with multiple cpp's. Besides, it's not great idea to have public constructor here.
Any thoughts?