#include<iostream>
#include<string>
#include <cstdlib>
using namespace std;
class Employee
{
public:
void AddInfo(void);
void ShowInfo(void);
void DeleteInfo(void);
void SearchInfo(void);
void ChangeInfo(void);
private:
char No;
string Name;
int Age;
string Sex;
string Section;
static int Count;
Employee *Pt;
};
int Employee::Count=0;
void Employee::AddInfo(void)
{
int n;
cout<<"請輸入新增的員工資訊數量";
cin>>n;cout<<endl;
Count=n;
Pt=new Employee[Count];
for(int i=0;i<n;i++)
{
cout<<"第"<<i+1<<"位員工工號:";
cin>>Pt[i].No;
cout<<"\n第"<<i+1<<"位員工姓名:";
cin>>Pt[i].Name;
cout<<"\n第"<<i+1<<"位員工性別:";
cin>>Pt[i].Sex;
cout<<"\n第"<<i+1<<"位員工年齡:";
cin>>Pt[i].Age;
cout<<"\n第"<<i+1<<"位員工部門:";
cin>>Pt[i].Section;
system("cls");
}
}
void ShowInfo(void)
{
cout<<" 員工資訊表"<<endl;
for(int i=0;i<Count;i++)
cout<<"工號:"<<Pt[i].No<<' '<<"姓名:"<<Pt[i].Name<<' '<<"性別:"<<Pt[i].Sex<<' '<<"年齡:"<<Pt[i].Age<<' '<<"部門:"<<Pt[i].Section<<endl;
}
void DeleteInfo(void)
{
int no,i;
cout<<"請輸入要洗掉資訊中的員工工號:";
cin>>no;cout<<endl;
for(i=0;i<Count;i++){
if(Pt[i].No==no)
{
for(int j=i+1;j<Count;j++)
Pt[j-1]=Pt[j];
}
}
Count--;
}
void SearchInfo(void)
{
int no,i;
cout<<"請輸入要查詢的員工工號";
cin>>no;
for(i=0;i<Count;i++){
if(Pt[i].No==no)
cout<<"工號:"<<Pt[i].No<<' '<<"姓名:"<<Pt[i].Name<<' '<<"性別:"<<Pt[i].Sex<<' '<<"年齡:"<<Pt[i].Age<<' '<<"部門:"<<Pt[i].Section<<endl;
}
if(i=Count) {cout<<"輸入錯誤!該工號不存在";}
}
void ChangeInfo(void)
{
int no,n;
cout<<"請輸入要修改資訊中的員工工號:";
cin>>no;cout<<endl;
for(int i=0;i<Count;i++){
if(Pt[i].No==no)
{
cout<<"請通過輸入數字選擇要修改的部分:1.姓名 2.性別 3.年齡 4.部門";
cin>>n;
switch(n)
{
case 1:
cout<<"請輸入修改后的姓名:";
cin>>Pt[i].Name;
case 2:
cout<<"請輸入修改后的性別:";
cin>>Pt[i].Sex;
case 3:
cout<<"請輸入修改后的年齡:";
cin>>Pt[i].Age;
case 4:
cout<<"請輸入修改后的部門:";
cin>>Pt[i].Section;
break;
default:
break;
}
}
}
cout<<"修改成功!";
}
int main()
{
int Item;//操作命令
Employee e1;//
while (1)
{
cout << endl;
cout << "1 輸入" << endl;
cout << "2 輸出" << endl;
cout << "3 洗掉" << endl;
cout << "4 查找" << endl;
cout << "5 修改" << endl;
cout << "_______________________" << endl;
cout << "請選擇操作命令:";
cin >> Item;
system("cls");//清屏
switch (Item)
{
case 1://輸入資訊
{
e1.AddInfo();
}
break;
case 2://輸出資訊
{
e1.ShowInfo();
}
break;
case 3://洗掉資訊
{
e1.DeleteInfo();
}
break;
case 4://查找資訊
{
e1.SearchInfo();
}
break;
case 5://修改資訊
{
e1.ChangeInfo();
}
break;
default:
break;
}
}
return 0;
}
C:\Users\86139\Desktop\人員\rrr.cpp(51) : error C2065: 'Count' : undeclared identifier
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2065: 'Pt' : undeclared identifier
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2228: left of '.No' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2228: left of '.Name' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2228: left of '.Sex' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2228: left of '.Age' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(52) : error C2228: left of '.Section' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(61) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(61) : error C2228: left of '.No' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(64) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(64) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(64) : error C2106: '=' : left operand must be l-value
C:\Users\86139\Desktop\人員\rrr.cpp(76) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(76) : error C2228: left of '.No' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2228: left of '.No' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2228: left of '.Name' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2228: left of '.Sex' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2228: left of '.Age' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(77) : error C2228: left of '.Section' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(88) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(88) : error C2228: left of '.No' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(96) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(96) : error C2228: left of '.Name' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(99) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(99) : error C2228: left of '.Sex' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(102) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(102) : error C2228: left of '.Age' must have class/struct/union type
C:\Users\86139\Desktop\人員\rrr.cpp(105) : error C2109: subscript requires array or pointer type
C:\Users\86139\Desktop\人員\rrr.cpp(105) : error C2228: left of '.Section' must have class/struct/union type
Error executing cl.exe.
rrr.obj - 39 error(s), 0 warning(s)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/234082.html
標籤:C++ 語言
上一篇:求助
