-1

我想在课堂上像私有变量一样使用 std::stringstream 。但我有一个错误“未声明的标识符”。请解释原因并告诉我我该怎么做。

class Test
{
private:
    std::stringstream str;    
}
4

1 回答 1

2

很可能您没有包含正确的头文件。另外,不要忘记类定义末尾的分号:

#include <sstream> // <== This is what you need for std::stringstream

class Test
{
private:
    std::stringstream str;    
}; // <== Don't forget the semicolon
于 2013-03-30T11:06:04.720 回答