初学者
打印职工信息
错误太多了
#include <stdio.h>
#include <string.h>
#define N 3
class Employee{
private :
char no[10];
char name[10];
char depart[10];
int age;
double salary;
public:
Employee();
void Creat(char na[],char n[],char de[],int ag,double sal);
void Display();
void Display(char n[]);
};
void Employee::Creat(Employee employ[N])
{
int i;
for(i=0;i<N;i++)
{
cout<<"input no:"<<endl;
cin>>employ[i].no;
cout<<"input name:"<<endl;
cin>>employ[i].name;
cout<<"input depart:"<<endl;
cin>>employ[i].depart;
cout<<"input age:"<<endl;
cin>>employ[i].age;
cout<<"input salary:"<<endl;
cin>>employ[i].salary;
}
}
void Employee::Display()
{
cout<<name<<no<<depart<<age<<salary<<endl;
}
void Display(char no[])
{
cout<<no<<name<<depart<<age<<salary<<endl;
}
void Display(char depart[])
{
cout<<depart<<no<<name<<age<<salary<<endl;
}
void main()
{
int i;
Employee employee[N];
Creat(employee);
cout<<"display all"<<endl;
for(i=0;i<N;i++)
employee[i].display();
cout<<"display according to no."<<endl;
for(i=0;i<N;i++)
employee[i].display(employee[i].no);
cout<<"display according to depart."<<endl;
for(i=0;i<N;i++)
employee[i].display(employee[i].depart);
}