我有一个先前声明的char c[64];,我正在尝试查看管道输出的第一个单词:
read(pipe_replacement_to_main[READ_END], c, BUF_SIZE);
istringstream response_stream(string(c));
string response_string;
getline(response_stream, response_string, ' ');在第四行,gcc给了我以下内容:
error: no matching function for call to ‘getline(std::istringstream (&)(std::string), std::string&, char)’我甚至不知道它是如何调用这个函数的。我声明istringstream错误了吗?
发布于 2011-12-10 05:53:54
Most vexing parse,在response_stream的构造函数中添加一对括号。
istringstream response_stream((string(c)));发布于 2011-12-10 05:56:07
这很好地展示了C++的真正“威力”。
按照声明response_stream变量的方式,它实际上是一个函数,而不是istringstream类型。
https://stackoverflow.com/questions/8452150
复制相似问题