0
//class
class student
{
public:
int rno;
string name;
int marks;
int ran;
void getinfo()
{ a:
cout<<"\t \tenter the roll number"<<endl;
cin>>rno;
cout<<"\t \tenter the name"<<endl;
getline(cin,name);
cout<<"\t \tenter the marks"<<endl;
cin>>marks;
}
void showinfo()
{
cout<<"\t"<<ran<<"\t "<<rno<<" \t\t"<<name<<" \t\t"<<marks<<endl<<endl;
}
};
当我给控制台中的一个对象的输入后,为滚动输入它没有打印“输入名称”,然后没有任何机会给它的输入显示“输入标记”的下一个打印语句。是否有任何理由为什么getline语句没有从控制台获取输入?getline语句没有得到输入
使用'cin.ignore()' –