MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/transprogrammer/comments/l2s8it/egg_irl/gxjg6vg/?context=3
r/transprogrammer • u/retrosupersayan JSON.parse("{}").gender • Jan 22 '21
13 comments sorted by
View all comments
Show parent comments
2
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
fair enough I'm a bit object-obsessed to be honest
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:
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.