You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

#pragma once
#ifndef PERSON_H
#define PERSON_H
#include <iostream>
#include <cstring>
#include <string>
#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