Arama butonu
Bu konudaki kullanıcılar: 1 misafir, 1 mobil kullanıcı
2
Cevap
583
Tıklama
0
Öne Çıkarma
Enum cin ile kullanımı?
B
12 yıl
Teğmen
Konu Sahibi

arkadaşlar cin ile kullanamıyorum ;
person.gender daki cin kısmındaki >> in altı çizili ve no operator ">>" matches these operands diyor


struct Person
{
enum Gender
{
Male,Female
}gender;
int IDNUM;
string Name;
int Age;
int Height;
string Profession;

};

void PersonData (Person &person)
{
Person person;
cout << "Please Enter the following details of the Person: " << endl;

cout << "Name: ";
cin >> person.Name;

cout << "Age: ";
cin >> person.Age;

cout << "Height (in cm): ";
cin >> person.Height;

cout << "Gender: ";
cin >> person.gender; //The Error is on this line. It also persists if I use getline

cout << "Profession: ";
getline (cin,person.Profession);;
}

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil



G
12 yıl
Yarbay

int olarak alıp enum a atabilirsin. 0 Male, 1 Female demek.


Bu mesaja 1 cevap geldi.
B
12 yıl
Teğmen
Konu Sahibi

şöyle birşey yaptım

char mf;
do {
cout << "Gender(M/F): ";
cin >> mf;
if(mf=='m' || mf=='M') person.gender=Male; else if(mf=='F' || mf=='f') person.gender=Female;
}while(mf!='M' && mf!='m' && mf!='F' && mf!='f');



DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.