Sure you can. But the moment you want to store the gender in some different way, or log a message whenever the gender is changed (because laws against cross-gender operations have been passed, for example) or want to enforce some restrictions, you're pretty much screwed with a variable. Getters/setters are future-oriented programming, and thanks to inlining, they're usually free in terms of runtime performance.Originally Posted by maxorator
No, it's not. First, nothing is a good thing to hold in a BOOL data type, because that's a Win32 "C has no bool" type. If anything, use a proper C++ bool.Also gender is a good thing to be hold in a BOOL data type.
It's also conceptually wrong. is_male could be boolean, or is_female. gender cannot be boolean - what does true mean? Make's me think of Austin Powers.
An enum is by far the best choice for gender. It's an enumeration of a finite and small set of possible values, namely "male" and "female".Form: Sex?
Austin: Yes, please!