c++输入流不等待提取运算符重载的输入
这个问题让我很烦恼。它不会等待输入,而是关闭。我已经尝试解决这个问题有一段时间了。有什么想法吗?
istream& operator>>(istream& is, Account &a) {
cout << "Enter an accoutn number: ";
is >> a.accountNo;
cout << endl;
cout << "Balance: ";
is >> a.bal;
return is;
}
This problem is annoying me. Instead of waiting for input, it just closes. I've been trying to figure this out for a while now. Any ideas?
istream& operator>>(istream& is, Account &a) {
cout << "Enter an accoutn number: ";
is >> a.accountNo;
cout << endl;
cout << "Balance: ";
is >> a.bal;
return is;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我将其放入以下程序时,它工作得很好(尽管如果您尝试从
std::cin
之外的任何内容读取帐户,它就不会工作得那么好):When I put it into the following program, it worked fine (though it wouldn't work so well if you tried to read an account from anything but
std::cin
):