作者:筱杰丶Jevon_879 | 来源:互联网 | 2022-12-13 19:04
我是C++编程的新手.我试图接受用户输入并将它们放在变量中,我正在使用cin
.它适用于整数和其他的除外strings
.所以,当我四处搜索时,发现我必须包含
标题.我只想了解,包含字符串标题会发生什么变化?我认为这cin
是由字符串标题中定义的函数重载.所以,我开始研究字符串标题,我找不到cin
重载或任何定义的函数.任何人都可以告诉我cin
在包括之后如何开始接受字符串输入
?
1> NathanOliver..:
定义功能
template
std::basic_ostream&
operator<<(std::basic_ostream& os,
const std::basic_string& str);
template
std::basic_istream&
operator>>(std::basic_istream& is,
std::basic_string& str);
这些免费的标准库函数允许您使用std::string
任何流来自或来自basic_ostream
或的流basic_istream
.