程序没错误没错误,可是运行不了

#include
#include
#include
using namespace std;
class work
{
public:
work(int n,string nam,int a,float wa)
{
num=n;name=nam;a=age;wag=wa;
}
friend ostream &operator <<(ostream &output,work &d)
{
output<<"号码:"<<d.num<<"姓名:"<<d.name<<"年龄:"<<d.age<<"工资:"<<d.wag;
return output;
}
protected:
int num,age;
string name;
float wag;
};
int main()
{
work data[5]={
work(1,"dongdong",21,5000),
work(2,"tongtong",21,4000),
work(3,"wenwen",2,50),
work(4,"huimei",23,3500),
work(5,"pingping",24,4000)
};
ofstream outfile("worker.dat");
if(!outfile)
{
cerr<<"open erreo!1"<<endl;
abort();
}
for(int i;i<5;i++)
outfile<<data[i]<<" "<<endl;
outfile.close();
return 0;
}

for(int i;i<5;i++)
这里没有给i初始值,编译都编译不过。还说没错误。

你看下编译出错错在哪里,出错类型是什么,不就知道了.

楼主,规范编程就不会出现这样的问题的

#include
#include
#include
头文件也没有啊?

最后输入的for循环的i没有初始化呀。

代码不全,没办法看啊

用的编译器编译没,还是只是用的编辑器保存了而已。

初学者把 编译的报警级别调高点。。或许发现很多问题

楼主,规范编程就不会出现这样的问题的