我有一个带有字符串流的类:
class NetMessageEncoder
{
std::stringstream m_ss;
std::stringstream m_numSS;
public:
NetMessageEncoder();
void beginMessage();
...
然后我有另一个类,其中包含该类的一个实例,我正在尝试制作一个向量:
m_games.resize(100);
该行产生:
Error 1 error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' c:\Program Files\Microsoft Visual Studio 9.0\VC\include\sstream 516
我认为这可能是因为向量需要复制类,我猜会导致字符串流按值复制还是什么?
stringstream 确实是原因,如果删除,编译得很好。
有没有办法解决这个问题?
谢谢
struct TableS
{
ServerPlayer* m_players[4];
SpadesGameInfo m_info;
NetSpadesGame m_game;
bool readyToPlay() const
{
int count = 0;
for(int i = 0; i < 4; ++i)
{
if(m_players[i])
{
count++;
}
}
return count >= m_info.getNumPlayers();
}
TableS()
{
for(int i = 0; i < 4; ++i)
{
m_players[i] = NULL;
}
}
};
class ServerCore : public ServerHost, public NetEventListener
{
NetEventDecoder m_dec;
NetEventEncoder m_enc;
std::vector<ServerPlayer*> m_players;
int m_totalPlayers;
std::vector<TableS> m_games;
public:
...