我有一个std::wstringstream
在我的类中用作缓冲区的东西,它被这个类中的大部分方法使用。但是,当我尝试做这样的事情时:
#include <sstream>
class foo
{
public:
void methodA(int x, int y); // Uses mBufferStream
void methodB(int x, int y); // Uses mBufferStream
private:
std::wstringstream mBufferStream;
};
我收到以下错误:
错误 C2248:“std::basic_ios<_Elem,_Traits>::basic_ios”:无法访问在类“std::basic_ios<_Elem,_Traits>”中声明的私有成员
这显然不是我的确切课程,但它是相同的设置。关于我可能做错了什么的任何想法?我正在使用 Microsoft Visual Studio 2005。
[编辑] 显示在 .cpp 文件中的方法主体中的使用(作为使用示例):
void foo::methodA(int x, int y)
{
mBufferStream << "From " << x << " To " << y;
externalfunction(mBufferStream.str()); // Prints to message service
mBufferStream.str(L"");
}