I have an enum class as follows:
enum class Age
{
Eleven,
Twelve,
Thirteen
};
Then I have a method called vector<Person> GetPeopleOfAge(Age age)
. What would be a good design so that a developer can call this and get the people with 11, 12 and 13? I can call it three times which is pretty bad but I did want to mention that I considered it. I can add an All
enumeration and do a check in my method but I don't like the idea of polluting the enum with enumerations like All
just to make my case work. I know it's a common method of solving this and some may disagree with me but to me it feels hacky and am looking for an alternative. Maybe I should use something other than an enum?
Aucun commentaire:
Enregistrer un commentaire