关于ofstream报错的问题
鬼夜哭 2015-03-21 03:51:35 以下是我编写的一个将数据保存到文本文件中去的程序,运行的时候报错,
error C2079: 'outfile' uses undefined class 'basic_fstream<char,struct std::char_traits<char> >'
error C2228: left of '.open' must have class/struct/union type
error C2228: left of '.close' must have class/struct/union type
请问是怎么回事?
#include<fstream>
#include<iostream>
void CShoeDlg::write()
{
extern double points[10000][6]; //记录点的坐标值和法向向量
extern int num_points; //点的数量
extern double inner_points[10000][3]; //缩进的点的坐标
int k=0;
fstream outfile;
outfile.open("myfile.txt",ios::out|ios::trunc);
if (!outfile)
{
cerr<<"open error"<<endl;
exit(1);
}
while(k<=num_points)
{
cout<<"points[k][0] "<<"points[k][1] "<<"points[k][2] "<<"points[k][3] "<<"points[k][4] "<<"points[k][5] "<<endl;
k++;
}
outfile.close();
}