标题:帮我看看这个程序,真不知道错了哪里??
取消只看楼主
renhu
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-11-27
 问题点数:0 回复次数:0 
帮我看看这个程序,真不知道错了哪里??

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


搜索更多相关主题的帖子: employee private include public 
2005-12-06 20:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-36962-1-1.html




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

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