新人求解
我有如下结构体:
typedef struct Point
{
int w;
CPoint point_begin;
CPoint point_end;
}Point;
typedef std::vector<Point> ar_point;
ar_point m_point;
存入一个文件中。用的如下函数:
void CDrawView::SaveFile(CString filename)
{
ofstream ofs(filename,ios::binary);
INT i = 0;
for(std::vector<Point>::iterator it = m_point.begin();it != m_point.end();it++)
{
ofs.write((char*)&m_point[i],sizeof(m_point));
i++;
}
ofs.close();
}
但是我在读取该文件的时候出现了编译的错误?
求教如何更改?
void CDrawView::LoadFile(CString filename)
{
ifstream ifs(filename);
Point m(0);
while(ifs.read((char*)&m,sizeof(Point)) > 0)
m_point.push_back(m);
ifs.close();
}
error C2146: syntax error : missing ';' before identifier 'm'
error C2065: 'm' : undeclared identifier
error C2678: binary '>' : no operator defined which takes a left-hand operand of type 'class std::basic_istream<char,struct std::char_traits<char> >' (or there is no accep
table conversion)
fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\drawView.sbr': No such file or directory
Error executing bscmake.exe.