| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 795 人关注过本帖
标题:求教c++问题,,,帮我看看这个程序,哪里有问题了啊,好多的错误不能运行, ...
取消只看楼主 加入收藏
caihua
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-6
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:4 
求教c++问题,,,帮我看看这个程序,哪里有问题了啊,好多的错误不能运行,谢谢大家
#include<iostream>
#include<string.h>
#include<fstream>
using namespace std;

class Employee
{
protected:
char name[20];
int num;
int rank;
float wages;
static int count;
public:
Employee();
void print();
friend class Head;
};
class Mansger:virtual public Employee{
public:
Mansger():Employee();
void print();
void save();
friend class Head;
}
class Salemansger:virtual public Employee
{
protected:
int sum;
public:
Salemansger():
Employee();
void print();
void save();
friend class Head;
};
class Technology:virtual public Employee
{
protected:
int time;
public:
Technology():Employee();
void print();
void save();
friend class Head;};
class Salesman:virtual public Employee
{
protected:
int sum1;
public:
Salesman():Employee();
void print();
void save();
friend class Head;
};
struck Linked
{
Employee *p;
Linked *next;
};
class Head
{
public:
Head();
void Insert(Employee *temp);
void Check();
void Delete();
void print();
~Head();
privata:
Linked *top;
};

EmployeeEmployee::Employee()
{
cout<<"输入姓名: ";
cin>>name;
++count;
num=count;
rank=1;
}
void Employee::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;
}
MansgerMansger::Mansger():Employee()
{
rank=4;
wages=8000;
}
void Mansger::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;
}
void Mansger::save()
{
ofstream fs("d:\\Mansger.txt");
fs<<wages;
cout<<"Mansger ok"<<endl;
}
SalemansgerSalemansger::Salemansger():Employee()
{
rank=3;
cout<<"输入部门销售总额: ";
cin>>sum;
wages=0.005*sum;
}
void Salemansger::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;
}
void Salemansger::save(){
ofstream fs("d:\\Salemansger.txt");
fs<<wages;
cout<<"Salemansger ok"<<endl;
}
TechnologyTechnology::Technology():Employee()
{
rank=3;
cout<<"输入工作时间: ";
cin>>sum;
wages=100*time;
}
void Technology::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;}
void Technology::save()
{
ofstream fs("d:\\Technology.txt");
fs<<wages;
cout<<"Technology ok"<<endl;
}
SalesmanSalesman::Salesman():Employee()
{
cout<<"输入月销售额: ";
cin>>sum1;
wages=0.04*sum1;
}
void Salesman::print(){
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;}
void Salesman::save()
{
ofstream fs("d:\\Salesman.txt");
fs<<wages;
cout<<"Salesman ok"<<endl;
}
HeadHead::Head()
{
if((top=new Linked)==NULL)exit(-1_);
top->next=NULL;
}
void Head::Insert(Employee *temp)
{
Linked *ttop=top;
while(ttop->next)
ttop=ttop->next;
ttop->next=new Linked;
ttop->next->p=temp;
ttop->next->next=0;
}
void Head::Check()
{
char s[20];
cout<<"输入要查找人的姓名: ";
cin>>s;
Linked *pbuf=top->next;
while(pbuf!=NULL)
{
if(strcmp(pbuf->p->name,s)!=0)
pbuf=pbuf->next;
else if(strcmp(pbuf->p->name,s)==0
{
cout<<"编号"<<pbuf->p->num<<" "<<"姓名"<<pbuf->p->name<<" "<<"等级"<<pbuf->p->rank<<" "<<"月薪"<<pbuf->p->wages<<endl;
}
pbuf=pbuf->next;
continue;
}
elsecout<<"查无此人"<<endl;
}
void Head::Delete()
{
int a;
cout<<"输入要删除人的编号: ";
cin>>a;
Linked *pbuf=top,*q;
while(pbuf->next!=NULL)
{
if(a!=pbuf->next->p->num)
pbuf=pbuf->next;
else if(a==pbuf->next->p->num)
{
q=pbuf->next;
pbuf->next=pbuf->next->next;
delete q;
cout<<"删除成功"<<endl;
}
elsecout<<"查无此人"<<endl;
}
void Head::print()
{
Linked *pbuf=top->next;
while(pbuf!=NULL)
{
pbuf->p->print();
pbuf=pbuf->next;
}
}
Head::~Head ()
{
Linked *ttop,*q;
ttop=top->next;
while(ttop!=NULL)
{
q=ttop;
ttop=ttop->next;
delete q;
}
}void mnue(Head *Data)
{
int n;
cout<<"请输入1、查找 2、删除 3、打印 0 退出:\n";
cin>>n;
switch(n)
{
case 1:
Data->Check();
break;
case 2:
Data->Delete();
break;
case 3:
Data->print();
break;
case 0:
break;
}
cout<<"是否继续继续请按1退出请按0";
cin>>n;
if(n!=0) mnue(Data);
}
void menu(Head *Data)
{
Mansger *M;Salemansger *S;
Technology *T;
Salesman *SA;
int n;
cout<<"请输入1、经理 2、销售经理 3、技术 4、销售员 0、退出:\n";
cin>>n;
switch(n)
{
case 1:
M=new Mansger;
M->save();
Data->Insert(M);
break;
case 2:
S=new Salemansger;
S->save();
Data->Insert(S);
break;
case 3:
T=new Technology;
T->save();
Data->Insert(T);
break;
case 4:
SA=new Salesman;
SA->save();
Data->Insert(SA);
break;
case 0:break;
}
cout<<"是否继续继续请按1退出请按0";
cin>>n;
if(n!=0) mnue(Data);
}
void main()
{
Head Data;
int n;
while(1)
{
cout<<"请输入(1 输入 2 其他操作 0 退出):\n";
cin>>n;
switch(n)
{case 1:
menu(&Data);
break;
case 2:
menu(&Data);
break;
case 0:
system("pause");
return;
}
}
system("cls");
}
搜索更多相关主题的帖子: void namespace include public friend 
2013-05-08 18:57
caihua
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-6
收藏
得分:0 
没有人吗
2013-05-08 19:25
caihua
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-6
收藏
得分:0 
回复 5楼 apull
你注释的语句是帮我改过了的还是有问题的,为什么在我电脑上运行时还是好多滴的错误,搞不懂啊
2013-05-09 13:21
caihua
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-6
收藏
得分:0 
回复 4楼 peach5460
我运行的时候下面报错说是:后的语句没有在}里边,从构造函数就开始有错误了
2013-05-09 13:24
caihua
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-6
收藏
得分:0 
回复 10楼 apull
谢谢你,我软件有问题
2013-05-10 10:06
快速回复:求教c++问题,,,帮我看看这个程序,哪里有问题了啊,好多的错误不能 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.045671 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved