为什么cin在包含String头之后接受字符串输入

InA*_*ash 1 c++ string iostream cin

我是C++编程的新手.我试图接受用户输入并将它们放在变量中,我正在使用cin.它适用于整数和其他的除外strings.所以,当我四处搜索时,发现我必须包含<string>标题.我只想了解,包含字符串标题会发生什么变化?我认为这cin是由字符串标题中定义的函数重载.所以,我开始研究字符串标题,我找不到cin重载或任何定义的函数.任何人都可以告诉我cin在包括之后如何开始接受字符串输入<string>

Nat*_*ica 5

<string> 定义功能

template <class CharT, class Traits, class Allocator>
std::basic_ostream<CharT, Traits>& 
    operator<<(std::basic_ostream<CharT, Traits>& os, 
               const std::basic_string<CharT, Traits, Allocator>& str);

template <class CharT, class Traits, class Allocator>
std::basic_istream<CharT, Traits>& 
    operator>>(std::basic_istream<CharT, Traits>& is, 
               std::basic_string<CharT, Traits, Allocator>& str);
Run Code Online (Sandbox Code Playgroud)

这些免费的标准库函数允许您使用std::string任何流来自或来自basic_ostream或的流basic_istream.