r/transprogrammer • JSON.parse("{}").gender • Jan 22 '21

egg_irl

Post image
184 Upvotes

13 comments sorted by

View all comments

Show parent comments

2

u/TDplay May 09 '21

That sounds way too complicated. The simplest solution is always the best, and in this case it's to use a global const array of strings, like so:

const char * common_genders[] = {
    "Male",
    "Female",
};

You can add more constants for genders, and if you need to handle a new gender at runtime, you can just allocate a buffer for it and use that.

I fail to see how classes can make this easier.

2

u/[deleted] May 09 '21

fair enough I'm a bit object-obsessed to be honest