下面的代码编译失败成员:的basic_stringbuf没有名为“冻结”
#include <cstdio>
#include <sstream>
int main()
{
std::ostrstream strm;
strm.rdbuf()->freeze(0);
}
我得到编译如下错误:
g++ sample3.cpp
sample3.cpp: In function 'int main()':
sample3.cpp:5: error: 'ostrstream' is not a member of 'std'
sample3.cpp:5: error: expected `;' before 'strm'
sample3.cpp:6: error: 'strm' was not declared in this scope
在谷歌搜索后,我怀疑我应该使用ostringstream到位ostrstream的,所以我已经修改如下程序:
#include <cstdio>
#include <sstream>
int main()
{
std::ostringstream strm;
strm.rdbuf()->freeze(0);
}
但现在我GE T中的以下错误:
g++ sample3.cpp
sample3.cpp: In function 'int main()':
sample3.cpp:6: error: 'struct std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >' has no member named 'freeze'
[freeze()](http://en.cppreference.com/w/cpp/io/streamreambuf/freeze)需要一个bool或没有,但不是int。 – Kevin
['std :: basic_stringbuf'](http://en.cppreference.com/w/cpp/io/basic_stringbuf)没有名为'freeze'的成员函数,为什么你认为它应该有? ['strsteambuf'](http://en.cppreference.com/w/cpp/io/strstreambuf)类是*弃用*,并且是在1998年C++标准化之前。 –
@Kevin我传递0来冻结这应该隐式类型转换为bool(“FALSE实际上) –