Using enumerations in classes
In another thread it was suggested to use an enum for gender in Human class.
Is this how you would implement the idea:
Code:
#include <iostream>
class Human
{
public:
enum gender {male, female}; //public, so they would be accessible in main()
Human(gender g): m_gender(g) {}
~Human() {};
gender getGender() //or should it return int?
{
return m_gender;
}
private:
gender m_gender; actual gender, therefore private
};
int main()
{
Human man(Human::male); //is this right?
Human woman(Human::female);
std::cout << man.getGender() << " " << woman.getGender() <<
std::endl;
std::cin.get();
}