diff --git a/student.h b/student.h new file mode 100644 index 0000000..cd90c5d --- /dev/null +++ b/student.h @@ -0,0 +1,50 @@ +#pragma once +#ifndef STUDENT_H +#define STUDENT_H +#include +#include +#include +#include "person.h" +using namespace std; +class Student : virtual public Person { +protected: + char studentNo[10]; + char schoolName[20]; + char classIn[20]; +public: + Student(); + Student(char* sname, char* sid, char* sgender, int y, int m, int d, char* sno, char* sschool, char* sclass); + ~Student() {}; + void setStudentNo(char* sno) { strcpy(studentNo, sno); } + char* getStudentNo() { return studentNo; } + void setschoolName(char* sschool) { strcpy(schoolName, sschool); } + char* getschoolName() { return schoolName; } + void setclassIn(char* sclass) { strcpy(classIn, sclass); } + char* getclassIn() { return classIn; } + virtual void inputData();//输入数据 + virtual void displayDetails(); //显示数据 +}; +Student::Student() :Person() { + strcpy(studentNo, "001"); + strcpy(schoolName, "null_schoolName"); + strcpy(classIn, "null_classIn"); +} +Student::Student(char* sname, char* sid, char* sgender, int y, int m, int d, char* sno, char* sschool, char* + sclass) :Person(sname, sid, sgender, y, m, d) { + strcpy(studentNo, sno); + strcpy(studentNo, sno); + strcpy(classIn, sclass); +} +void Student::inputData() { + Person::inputData(); + cout << "StudentNo: "; cin >> studentNo; + cout << "school: "; cin >> schoolName; + cout << "classIn: "; cin >> classIn; +} +void Student::displayDetails() { + Person::displayDetails(); + cout << "studentNo: " << studentNo << endl; + cout << "schoolName: " << schoolName << endl; + cout << "classIn: " << classIn << endl; +} +#endif //STUDENT_H \ No newline at end of file