資源簡介
這是我們的課程設計報告,是一個管理系統,主要是對個人信息的創建、刪除、查詢、統計等基本操作,個人覺得還不錯哦!

代碼片段和文件信息
#include
#include
#include“Ballplayer.h“
using?namespace?std;
int?Ballplayer::num=0;???//初始化球員總人數
Ballplayer::Ballplayer()??//定義構造函數
{}
void?Ballplayer::creat()??//定義創建新球員信息函數
{
cout< ????cout< cin>>number;
cout< cin>>name;
string?str;
while(1)??????????//安全性檢查
{
cout< cin>>str;
if(str==“男“?||?str==“女“)
break;
cout< }
strcpy(sexstr.c_str());?//確定性別
cout< cin>>type;
cout< num++;?????????//每調用一次該函數,球員總人數增加1
ofstream?outfile(“Database.dat“ios::app|ios::binary);??//打開“test.dat“文件,并將指針指向文件尾
outfile.write((char*)(this)sizeof(*this));??????//將所輸入的信息追加到文件尾部
outfile.close();
}
void?Ballplayer::creat(char*?str1char*?str2char*?str3char*?str4)??//重載創建新球員信息函數
{
strcpy(numberstr1);
strcpy(namestr2);
strcpy(sexstr3);
strcpy(typestr4);
num++;?????????//每調用一次該函數,球員總人數增加1
ofstream?outfile(“Database.dat“ios::app|ios::binary);??//打開“test.dat“文件,并將指針指向文件尾
outfile.write((char*)(this)sizeof(*this));??????//將所輸入的信息追加到文件尾部
outfile.close();
}
void?Ballplayer::searchnum()???//定義按編號查找信息函數
{
bool?findmark=0;
string?temp;
cout< cout< cin>>temp;
ifstream?infile(“Database.dat“ios::binary);
infile.read((char*)(this)sizeof(*this));???//讀取一個類對象數據,放入*this中
while(!infile.eof())
{
if(strcmp(numbertemp.c_str())==0)
{
cout< cout<<(*this)< infile.close();
findmark=1;
}
infile.read((char*)(this)sizeof(*this));??//文件指針沒到達文件尾,循環讀取數據
}
infile.close();
if(!findmark)
cout< }
void?Ballplayer::searchname()???//定義按姓名查找信息函數
{
bool?findmark=0;
string?temp;
cout< cout< cin>>temp;
ifstream?infile(“Database.dat“ios::binary);
infile.read((char*)(this)sizeof(*this));???//打開文件,讀取數據
while(!infile.eof())
{
if(strcmp(nametemp.c_str())==0)
{
cout< cout<<(*this)< infile.close();
findmark=1;
}
infile.read((char*)(this)sizeof(*this));//文件指針未到文件尾,循環讀取數據
}
infile.close();
if(!findmark)
cout< }
void?Ballplayer::delnum()??//定義按編號刪除信息函數
{
????int?delmark=0;????//用于標記該編號信息是否已找到
string?temp;
cout< cout< cin>>temp;
ifstream?infile(“Database.dat“ios::binary);???//打開用于讀的二進制文件“Database.dat“
ofstream?outfile(“Temp.dat“ios::binary);?????//打開用于寫的二進制文件“Temp.dat“
infile.read((char*)(this)sizeof(*this));????//從“test.dat“中讀取一個類對象數據放入*this中
while(!
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7334??2010-03-09?18:15??學院球員管理系統\Ballpla
?????文件???????1035??2010-03-09?17:31??學院球員管理系統\Ballpla
?????文件???????2276??2010-05-04?10:50??學院球員管理系統\Management.cpp
?????文件????????278??2010-03-08?21:12??學院球員管理系統\Management.h
?????文件????????150??2010-03-09?17:31??學院球員管理系統\學院球員管理系統.cpp
?????目錄??????????0??2010-05-04?10:53??學院球員管理系統
-----------?---------??----------?-----??----
????????????????11073????????????????????6
- 上一篇:hive&sqoop;的ppt
- 下一篇:嵌入式LINUX下WEB服務器的設計與實現
評論
共有 條評論