c++ getline的参数

img


为什么这段代码中的getline用法跟他这个系统注释的不一样呢?

以下是源代码:

#include<iostream>
#include<cstdlib>
#include<fstream>
#include<cstring>
using namespace std;

void test01()
{
    ifstream ifs;
    ifs.open("test.txt",ios::in);
    
    if(!ifs.is_open()){
        cout<<"打开失败"<<endl;
        return;
    }
    //读数据 

    
    3.
    string buf;
    while(getline(ifs,buf))
    {
        cout<<buf<<endl;
    }
    
    ifs.close();
}

int main()
{
    test01();
    system("pause");
    return 0;
}

getline有很多重载形式,你看提示那里 3/9左右有箭头,可以翻看别的形式

getline 是有多个重载的呀,而且那个不叫注释,而是语法提示。