資源簡介
設計學校人事管理程序,并對相關對象進行管理;
至少包括:人類、學生類、教師類、員工類、兼職學生等,設計類之間的層次結構。設計各類的屬性和行為。并完成各類對象的管理。
至少包括:人類、學生類、教師類、員工類、兼職學生等,設計類之間的層次結構。設計各類的屬性和行為。并完成各類對象的管理。
代碼片段和文件信息
#include
#include
#include
using?namespace?std;
class?Date
{
public:
int?year;
int?month;
int?day;
Date(int?year1?=?0?int?month1?=?0?int?day1?=?0);
};
Date::Date(int?year1?int?month1?int?day1)
{
year?=?year1;
month?=?month1;
day?=?day1;
}
//時間類
class?Person
{
protected:
string?Name;//姓名
string?sex;//性別
int?age;//年齡
public:
Person(string?name?string?sex?int?a);
};
//人類
Person::Person(string?name?string?s?int?a)
{
Name?=?name;
sex?=?s;
age?=?a;
}
class?Student?:public?Person
{
protected:
string?Number;//學號
int?Score;//成績
public:
Student(string?name?=?“?“?string?s?=?“?“?int?a?=?0?string?number?=?“?“?int?score?=?0);
friend?bool?operator>(Student&?t1?Student&?t2);
void?show();
};
//學生類
void?Student::show()
{
cout?<“姓名:“?<}
Student::Student(string?name?string?s?int?a?string?number?int?score)?:Person(name?s?a)
{
Number?=?number;
Score?=?score;
}
bool??operator>(Student&?s1?Student&?s2)
{
if?(s1.Score?>?s2.Score)
return?true;
else
return?false;
}
void??paixustu(Student*?s)
{
Student?temp;
for?(int?i?=?0;?i?5;?i++)
{
for?(int?j?=?i;?j?5;?j++)
{
if?(s[i]?>?s[j])
{
temp?=?s[i];
s[i]?=?s[j];
s[j]?=?temp;
}
}
}
}//對學生的成績按從高到低排序
class?teacher?:public?Person
{
Date?worktime;//參加工作日期
public:
teacher(string?name?=?“?“?string?s?=?“?“?int?a?=?0?int?year1?=?0?int?month1?=?0?int?day1?=?0);
friend?bool?operator<(teacher&?t1?teacher&?t2);
friend?ostream&?operator<<(ostream&?out?teacher&?t1);
};
//教師類
teacher::teacher(string?name?string?s?int?a?int?year1?int?month1?int?day1)
:Person(name?s?a)?worktime(year1?month1?day1)
{
}
ostream&?operator<<(ostream&?out?teacher&?t1)
{
out?<“姓名:“?< return?out;
}
bool?operator<(teacher&?t1?teacher&?t2)
{
if?(t1.worktime.year?>?t2.worktime.year)
return?true;
else?if?(t1.worktime.year?==?t2.worktime.year)
{
if?(t1.worktime.month?>?t2.worktime.month)
return?true;
else
if?(t1.worktime.month?==?t2.worktime.month)
{
if?(t1.worktime.day?>?t2.worktime.day)
return?true;
else?if?(t1.worktime.day?=?t2.worktime.day)
if?(t1.age?>?t2.age)
return?true;
}
}
return?false;
}
void?paixu(teacher*
- 上一篇:C語言考研真題匯編
- 下一篇:高斯平均引數法正反算
評論
共有 條評論