diff --git a/person.h b/person.h new file mode 100644 index 0000000..af360a2 --- /dev/null +++ b/person.h @@ -0,0 +1,56 @@ +#pragma once +#ifndef PERSON_H +#define PERSON_H +#include +#include +#include +#include "date.h" +using namespace std; +#pragma warning(disable:4996) +class Person +{ +protected: + char id[18]; + char name[20]; + char gender[6]; + Date birthday; +public: + Person(); + Person(char* sname, char* sid, char* sgender, int y, int m, int d); + ~Person() {}; + void setName(char* sname) { strcpy(name, sname); } + char* getName() { return name; } + void setId(char* sid) { strcpy(id, sid); } + char* getId() { return id; } + void setGender(char* sgender) { strcpy(gender, sgender); } + char* getGender() { return gender; } + void setBirthday(Date d) { birthday = d; } + Date getBirthday() { return birthday; } + virtual void inputData();//输入数据 + virtual void displayDetails(); //显示数据 +}; +Person::Person() {//默认构造 + strcpy(name, "null"); + strcpy(gender, "男"); + strcpy(id, "0"); + birthday = Date(1980, 1, 1); +} +Person::Person(char* sname, char* sid, char* sgender, int y, int m, int d) {// + strcpy(name, sname); + strcpy(gender, sid); + strcpy(id, sgender); +} +void Person::inputData() {//修改或输入数据 + cout << "name: "; cin >> name; + cout << "ID: "; cin >> id; + cout << "gender: "; cin >> gender; + cout << "birthday: " << endl; birthday.inputDate(); +} +void Person::displayDetails() {//输出数据 + cout << "name: " << name << endl; + cout << "ID: " << id << endl; + cout << "gender: " << gender << endl; + cout << "birthday" << endl; + birthday.displayDate(); +} +#endif //PERSON_H \ No newline at end of file