<分区>
我正在努力学习C++,但仍然不断遇到愚蠢的问题,因为我还不熟悉C++库,以及常见错误等。
现在,我的以下代码片段失败了:
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
void getInt(int & val){
string output;
getline(cin output.c_str());
val = atoi(output.c_str());
}
当我尝试编译它时给我这个错误:
test.cpp: In function void getInt(int&):
test.cpp:51: error: expected ) before output
test.cpp:51: error: no matching function for call to getline(std::istream&)
我做错了什么?我觉得我错过了一些明显的东西。