Apparently operator>> doesn't convert person_t to int.
You could tryint g; cin>>g; person1.gender = person_t::Gender_T(g); though I'm not sure this will work.
If you want the app to make sense and ask for a word "male" or "female" you'll have to put a little more work into it.
#include <cctype>
#include <iomanip>
#include <iostream>
usingnamespace std;
...
istream& operator >> ( istream& ins, person_t::Gender_T& gender )
{
staticconstchar* valid = "female";
unsigned index;
ins >> skipws;
// Figure out whether the initial input is acceptable
switch (tolower( ins.peek() ))
{
case'm': gender = person_t::MALE; index = 2; break;
case'f': gender = person_t::FEMALE; index = 0; break;
}
// Scan past the word "male" or "female", checking to see that
// it is correct along the way. Abbreviated forms are OK.
if (ins)
{
while (valid[ index ] && isalpha( ins.peek() ))
{
// Is the potential input invalid?
if (tolower( ins.peek() ) != valid[ index ])
{
ins.setstate( ios::badbit );
break;
}
// It is OK. Read it so that we can check the next potential input.
ins.get();
index++;
}
}
return ins;
}
Writing insertion operators is significantly easier: