我的类包含一个ofstream
文件,当使用迭代器删除此类对象向量的对象时遇到问题。
这是错误:
Error 10 error C2249: 'std::basic_ios<_Elem,_Traits>::operator =' : no accessible path to private member declared in virtual base 'std::basic_ios<_Elem,_Traits>' c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream
代码:
static vector<VOIP> calls;
...
for(...)
{
VOIP v = VOIP(...);
calls.push_back(v);
}
...
for( int i = 0 ; i < calls.size() ; i++)
{
if(...)
{
vector<VOIP>::iterator it = calls.begin() + i;
calls.erase(it);//"?"
break;
}
}
面对错误 C2249 从“?”行引发,任何帮助,这就是类
class VOIP
{
public:
VOIP(string SourceDirectoryPath, string startTime, signalling sig, int callerIp[], int calleeIp[], int callerPort, int calleePort);
VOIP(const VOIP & voip);
~VOIP(void);
//caller and callee voice vectors
vector<u_char> callerVoiceVector;
vector<u_char> calleeVoiceVector;
//caller and callee voice files and path
ofstream callerVoiceFile;
ofstream calleeVoiceFile;
string outFilePath;
string log;
ofstream logFile;
string startTime;
string endTime;
string length;
}
复制构造函数中的注释行引发相同的错误,即错误 C2249
VOIP::VOIP(const VOIP & voip)
/*:calleePort(voip.calleePort), calleeVoiceFile(voip.calleeVoiceFile), calleeVoiceVector(voip.calleeVoiceVector),
callerPort(voip.callerPort), callerVoiceFile(voip.callerVoiceFile), callerVoiceVector(voip.callerVoiceVector),
callType(voip.callType), endTime(voip.endTime), length(voip.length), log(voip.log), logFile(voip.logFile),
outFilePath(voip.outFilePath), startTime(voip.startTime),
pleaseDial(voip.pleaseDial), DLHmm(voip.DLHmm)//signalings*///TODO
{
cout<<"inside copy constractor"<<endl;
}
VOIP::~VOIP(void)
{
callerVoiceVector.clear();
calleeVoiceVector.clear();
callerVoiceFile.close();
calleeVoiceFile.close();
logFile.close();
cout<<"inside destractor"<<endl;
}