第二次作业。
This commit is contained in:
15
OOP/EmployeeAdmin/employee.h
Normal file
15
OOP/EmployeeAdmin/employee.h
Normal file
@@ -0,0 +1,15 @@
|
||||
class Employee {
|
||||
private:
|
||||
int individualEmpNo;
|
||||
int grade;
|
||||
int accumPay;
|
||||
|
||||
public:
|
||||
Employee();
|
||||
Employee(int no, int newGrade, int newAccumPay);
|
||||
~Employee();
|
||||
void printInfo();
|
||||
void setEmpNo(int);
|
||||
void setGrade(int);
|
||||
void setAccumPay(int);
|
||||
};
|
||||
50
OOP/EmployeeAdmin/main.cpp
Normal file
50
OOP/EmployeeAdmin/main.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <iostream>
|
||||
#include "employee.h"
|
||||
|
||||
Employee::Employee() {
|
||||
this->individualEmpNo = 0;
|
||||
this->grade = 0;
|
||||
this->accumPay = 0;
|
||||
}
|
||||
|
||||
Employee::Employee(int no, int newGrade, int newAccumPay) {
|
||||
this->individualEmpNo = no;
|
||||
this->grade = newGrade;
|
||||
this->accumPay = newAccumPay;
|
||||
}
|
||||
|
||||
Employee::~Employee() {
|
||||
std::cout << "欢迎使用,再见" << std::endl;
|
||||
}
|
||||
|
||||
void Employee::printInfo() {
|
||||
std::cout << "Employee No. " << this->individualEmpNo << ": grade " << this->grade << ", accumPay: " << this->accumPay << std::endl;
|
||||
}
|
||||
|
||||
void Employee::setEmpNo(int newNo) {
|
||||
this->individualEmpNo = newNo;
|
||||
}
|
||||
|
||||
void Employee::setGrade(int newGrade) {
|
||||
this->grade = newGrade;
|
||||
}
|
||||
|
||||
void Employee::setAccumPay(int newAccumPay) {
|
||||
this->accumPay = newAccumPay;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Employee* staff[4];
|
||||
staff[0] = new Employee();
|
||||
staff[1] = new Employee(11343, 2, 2000);
|
||||
staff[2] = new Employee(199, 1, 4000);
|
||||
staff[3] = new Employee(59949, 4, 400);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
staff[i]->printInfo();
|
||||
}
|
||||
|
||||
delete staff[3];
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user