client defined enums

Feb 25, 2019 at 10:24pm
Hi

I'm writing a library, which will allow clients/users to interact with an object E. E has different properties but one of the member variables stores an enum. I have defined a list of enums which the client can set the variable as but I'd like the user to be able to define their own enums.

Is this possible?

Thanks

Feb 26, 2019 at 12:43am
it depends :)

now, if you had some magic class called "properties"
and that lived inside another class called "OOO"
you might have something cool like this
class OOO
{
vector <properties> ps; //and accessor functions and something that fills it in and stuff like that, right?
}


the the client can have his own enum…
lets call some functions I didn't write above with names that let you guess what they do:

enum myenum{a,b,c,d, enum_max};
OOO var;
var.allocate_properties(enum_max);
var[a].setproperty(value); //overload the [] operator maybe? to access the vector directly, or whatever design...

is this along the lines of something you meant?



Last edited on Feb 26, 2019 at 12:44am
Topic archived. No new replies allowed.