資源簡介
第一實踐寫的C++,可能很多地方不完善
#include
#include
#include
using namespace std;

代碼片段和文件信息
#include?
#include
#include
using?namespace?std;?
class?company_staff////定義公司員工類
{friend?void??register_1();//定義注冊函數(shù)將注冊函數(shù)設(shè)置為一般函數(shù),并設(shè)置為class?company_staff的友員函數(shù)
private:
char?name[20];//定義私有數(shù)據(jù)name
char?NO[15];//定義私有數(shù)據(jù)no
int?wage;//定義私有數(shù)據(jù)wage
char?job[20];//定義私有數(shù)據(jù)job
int?age;//定義私有數(shù)據(jù)age
char?sex[15];//定義私有數(shù)據(jù)sex
public:
void?show_menu();//定義輸出菜單選擇函數(shù)
void?search();//定義查詢函數(shù)
void?revise();//定義修改數(shù)據(jù)函數(shù)
void?paixu();//對所有員工工資從小到大排序
int?renshu();//查詢已經(jīng)注冊了多少個人
void?delete_1();//刪除員工數(shù)據(jù)成員函數(shù)
void?main_1();
};
class?manager:public?company_staff//建立經(jīng)理派生類
{friend?void??register_1();//設(shè)置注冊函數(shù)為manager的友員函數(shù)
public:
int?m_wage();//經(jīng)理的工資計算函數(shù)
};
int?manager::m_wage()//返回經(jīng)理工資的成員函數(shù)
{
return?8000;//返回經(jīng)理的工資
}
class?sell_manager:public?company_staff//建立銷售經(jīng)理派生類
{
public:
int?s_m_wage();//銷售經(jīng)理的工資計算函數(shù)
};
int?sell_manager::s_m_wage()
{???
cout<<“銷售經(jīng)理的工資為底薪(5000)+所轄部門銷售額總額*0.5%;\n請輸入銷售部門銷售額總額!“< int?zong;
cin>>zong;
return?(5000+zong*0.005);//返回銷售經(jīng)理的工資
}
class?sellman:public?company_staff//建立銷售員派生類
{
public:
int?sellman_wage();//銷售員的工資計算函數(shù)
};
int?sellman::sellman_wage()
{cout<<“銷售員的工資為銷售額*4%提成;\n請輸入銷售額!“< ??int?xiaoshoue;
??cin>>xiaoshoue;
return?(xiaoshoue*0.04);//返回銷售員的工資
}
class?technician:public?company_staff//建立技術(shù)員派生類
{
public:
int?t_wage();//技術(shù)員的工資計算函數(shù)
};
int?technician::t_wage()
{cout<<“技術(shù)員工資為工作時間*小時工資(100元每小時)\n請輸入工作時間!“< ?int?worktime;
?cin>>worktime;
return?(worktime*100);//返回技術(shù)員的工資
}
int?company_staff::renshu()//此函數(shù)實現(xiàn)返回已經(jīng)注冊多少人的數(shù)值
{
company_staff?staff[50];
????fstream?iofile(“員工信息.dat“ios::in|ios::binary);//打開二進制文件,以讀入方式打開
????if(!iofile)//如果打不開直接退出程序
????{
????cerr<<“你的程序文件夾下文創(chuàng)建“員工信息.dat”文件,請先創(chuàng)建!“< ????abort();
}
int?k=0;
for(int?j=0;j<50;j++)//對50人進行循環(huán)遍歷
????{iofile.seekg(j*sizeof(staff[j])ios::beg);?????//文件定位于第n個員工的數(shù)據(jù)
????????iofile.read((char*)&staff[j]sizeof(staff[0]));//讀出第n個員工的數(shù)據(jù)
?if(staff[0].age<0)
?k=0;
?else
???if(staff[j].age>0)//對第j人的數(shù)據(jù)的年齡進行判斷,若有年齡j序號數(shù)組里有員工數(shù)據(jù)
???????k=k+1;//有員工數(shù)據(jù)的,k值加1
???else
???break;
}
return(k);
iofile.close();
}
void?company_staff::show_menu()//進入公司員工管理系統(tǒng)幾面提示語函數(shù)
{
cout<<“★★☆☆☆歡迎進入公司員工管理系統(tǒng)☆☆☆★★??“< cout<<“★★☆☆???????請選擇所需服務(wù)???????☆☆★★??“< cout<<“★★☆?????????1.注冊新職工;?????????☆★★??“< cout<<“★★???????????2.查詢職工信息;?????????★★??“< cout<<“★?????????????3.修改職工信息;???????????★??“< cout<<“★?????????????4.刪除員工信息;???????????★??“< cout<<“★?????????????5.查看各職工工資;?????????★??“< cout<<“★?????????????6.退出系統(tǒng)。???????????????★??“< cout<<“★★★★★★★★☆☆☆☆☆☆★★★★★★★★??“< }
///////注冊函數(shù)體
void??register_1()//員工注冊成員函數(shù)
{? int?company_staff::renshu();
company_staff?staff[50];//定義company_staff?staff[50]
????fstream?iofile(“員工信息.dat“ios::out|ios::app|ios::in|ios::binary);//打開二進制文件,以可讀可寫的方式打開
???for(int?i=staff[50].renshu();i<=50;i++)//循環(huán)注冊,并且令i的初值等于現(xiàn)在要注冊的員工的序號
??{?
cout<<“歡迎進入員工注冊系統(tǒng)“< ???if(staff[50].ren
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????33792??2010-06-10?14:00??公司員工管理系統(tǒng)\H1.ncb
?????文件????????238??2010-06-10?14:00??公司員工管理系統(tǒng)\H1.PLG
?????文件??????48640??2010-06-10?14:00??公司員工管理系統(tǒng)\H1.OPT
?????文件????????529??2010-06-10?14:00??公司員工管理系統(tǒng)\H1.DSW
?????文件??????20066??2010-06-10?14:00??公司員工管理系統(tǒng)\Cpp2.cpp
?????文件??????20066??2010-06-10?14:01??公司員工管理系統(tǒng)\Cpp1.cpp
?????文件???????3377??2010-06-10?14:01??公司員工管理系統(tǒng)\Cpp2.dsp
?????文件??????82944??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug\vc60.idb
?????文件?????126976??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug\vc60.pdb
?????文件????2189872??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug\Cpp2.pch
?????文件?????414553??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug\Cpp2.obj
?????文件?????832468??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug\Cpp2.ilk
?????文件?????577599??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug\Cpp2.exe
?????文件????1147904??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug\Cpp2.pdb
?????文件????????736??2010-06-10?14:01??公司員工管理系統(tǒng)\Cpp2.plg
?????文件??????????0??2010-06-10?14:01??公司員工管理系統(tǒng)\員工信息.DAT
?????文件??????48640??2010-06-10?14:01??公司員工管理系統(tǒng)\Cpp2.opt
?????文件????????533??2010-06-10?14:01??公司員工管理系統(tǒng)\Cpp2.dsw
?????目錄??????????0??2010-06-10?14:01??公司員工管理系統(tǒng)\Debug
?????目錄??????????0??2010-06-10?13:57??公司員工管理系統(tǒng)
-----------?---------??----------?-----??----
??????????????5548933????????????????????20
評論
共有 條評論