找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 1179|回复: 2

帮我看看这个程序,真不知道错了哪里??

[复制链接]
发表于 2009-11-1 00:22:16 | 显示全部楼层 |阅读模式 IP:江苏扬州
#include<iostream>
#include<string>
using namespace std;
const int maxe=100;
int top=0;
class employee{
public:
employee(string,string,int,int,int);

void setname(string,string);
void setdata(int,int,int);
void getname() const;
void getdata() const;
void printemployee() const;
private:
string firstname;
string lastname;
int day;
int year;
int month;
};
employee::employee(string wfirst,string wlast,int wmonth,int wday,int wyear)
{

setname(wfirst,wlast);
setdata(wmonth,wday,wyear);
top++;
}
void employee::setname(string wfirst,string wlast)
{
firstname=wfirst;
lastname=wlast;
}
void employee::setdata(int wmonth,int wday,int wyear)
{
month=wmonth;
day=wday;
year=wyear;
}
void employee::getname() const
{
cout<<"name : "<<firstname<<" "<<lastname<<endl;
}
void employee::getdata() const
{
cout<<"date :"<<month<<'/'<<day<<'/'<<year<<endl;
}

void employee::printemployee() const
{
getname();
getdata();
}
int main()
{
employee *ptr[maxe];

ptr[0]=new employee("xiao","min",11,21,1984);
ptr[1]=new employee("xiao","gang",9,23,1983);

int choice=1;
int i;
string ufirst;
string ulast;
int umonth;
int uyear;
int uday;

while(choice!=0)
{
cout <<endl<<endl<<"\t\t\t weclome to employee system \n\n\n";
cout <<"\t\t\t1.list\n\n\t\t\t2.add\n\n\t\t\t3.change\n\n\t\t\t4.leave"<<endl;
cin >>choice;

switch(choice)
{
case 1:
for(i=0;i<top;i++)
ptr[i]->printemployee();break;

case 2:
cout<<"please enter the employee.the firstname :";
cin>>ufirst;
cout<<" the lastname :";
cin>>ulast;
cout<<" the birthday.the month :";
cin>>umonth;
cout<<" the day :";
cin>>uday;
cout<<" the year :";
cin>>uyear;
int temp=top;
ptr[temp]=new employee(ufirst,ulast,umonth,uday,uyear);
break;
case 3:

cout<<"enter the full name.the firstname: ";
cin>>ufirst;
cout<<"the lastname: ";
cin>>ulast;

for(i=0;i<top;i++)
if(ufirst==ptr[i]->firstname && ulast==ptr[i]->lastname)
{
cout<<"1,change name\n2,change date\n";
cin>>choice;
switch(choice)
{
case 1: cout<<"enter the new name";
cin>>ufirst>>ulast;
ptr[i]->setname(ufirst,ulast);break;

case 2: cout<<"enter the new date";
cin>>umonth>>uday>>uyear;
ptr[i]->setdata(umonth,uday,uyear);break;
}
}
cout<<"no one here!!!!!"<<endl;break;
}
}
return 0;
}
发表于 2009-11-1 00:22:18 | 显示全部楼层 IP:江苏扬州
开头的包含头文件少了后缀.h了
回复

使用道具 举报

发表于 2009-11-1 00:22:18 | 显示全部楼层 IP:江苏扬州
楼上的不知道就不要乱说

firstname和lastname是priavte的 外部访问不到
做一个接口或者改成public的

然后把temp指针的声明放在switch前面
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 19:31 , Processed in 0.279568 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表