std::getline在std::string存在的原理是什么?

What principle of presence std::getline in std::string?

我正在尝试弄清楚 class std::string 获取方法 std::getline[=32 在哪里=] 来自?据说这个method is non-member function of std::string and it's overloaded in std::string。但是 getline 存在的开始在哪里?将它放入 std::string class 的顺序是什么?这个方法是从某处继承而来的,还是只是出现在无人区的 class std::string 的文件中?它与std::istreamgetline有关吗? std classes的继承结构有明确的描述吗?考虑这样的 std lib 结构会很方便。遗产。也许它在某些文档中 e。吨。 c.

其实这里有两个问题:

  1. getline 与继承等事物相关的出现机制
  2. 忽视std继承结构

谢谢!

where does class std::String

没有classstd::String。您可能打算编写确实存在的 std::string

get method std::getline from?

std::string 没有这样的成员函数。有一个使用该名称的免费函数(模板)。

It's said that this method is non-member function of std::String and it's overloaded in std::String.

说那些话是错误的。 std::getline 是一个 non-member 函数(模板),但它不是“std::String”。在 C++11 中引入了一个重载重载 istream 参数,但不是“in std::String”。

But where is commencement of getline existence?

std::getline 定义在标准 header <string>.

What order of getting it into std::String class?

它不是“在 std::String class”。

Is this method inherited from somewhere

没有

Is it related to getline of std::istream?

不是 C++ 继承意义上的。但它们是共享相同名称并实现相同抽象概念的函数。一个将任意长度的输入读取到可调整大小的 std::string 中,另一个读取到任何字符缓冲区,但最大为恒定大小。

Is there some explicit description of inheritance structure of std classes?

是的。标准文档是权威来源,规定了哪些标准classes保证继承哪些。