std::string str;
std::stringstream strm(str);

我收到此错误:

  

错误11错误C2248:   '的std :: basic_ios< _Elem,_Traits> :: basic_ios'   :无法访问私人会员   在课堂上宣布   '的std :: basic_ios< _Elem,_Traits>' C:\程序   files \ microsoft visual studio   9.0 \ vc \ include \ sstream 517

如果我使用istringstream,也会发生同样的情况。

编译器:Visual C ++ 2008。

有帮助吗?

解决方案

听起来您正在尝试复制流。这是不可能的,因为复制构造函数是私有的。

其他提示

#include <string>
#include <sstream>

int main( int argc, char *argv[] ) {
    std::string str;
    std::stringstream strm( str );

    return 0;
}

在VS 2008中为我编译好没有错误/警告。你能发布完整的代码吗?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top