qq_21918325 2015-05-25 10:35 采纳率: 0%
浏览 1944

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

#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;
}

  • 写回答

9条回答

  • threenewbee 2015-05-25 10:44
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试