Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use C++ Code to realize School personnel Management system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use C++ code to achieve the relevant knowledge of the school personnel management system, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe that you will gain something after reading this article on how to use C++ code to achieve the school personnel management system. Let's take a look.

Topic requirement

School personnel management system

1. Establish a school class, which defines the increase function of adding personnel according to their names, the deletion function of personnel and the query function (subject to the name).

2. Establish a personnel base class with name and gender attributes and an output function (which can be defined as a virtual function).

3. Establish an employee class and a student class, both of which are inherited from the personnel class. Requirements: you can output the attributes of the employee class (student class) object (such as name, gender and work permit number or student number), and write the specific implementation of their output function respectively.

4. Overload "> >" and use cin to assign values to employee class, student class and on-the-job student class. (choose to do)

5. Write the main () main function, test the above functions, and add, delete and query all kinds of people in the way of menu (with the name as the clue).

6. The program should adopt multi-file structure.

7. Vs2019 compilation

Experimental source code

Head.h header file function declaration

/ * header file Head.h, name all required functions or system header files * / / system header file # include#includeusing namespace std;// global variable extern int p; / / Save human number extern int Re;// save current student digits extern int Rs;// save current employee digits / save student numbers extern int eSpac / save employees / / global class array statement extern int maxEmployee Extern int maxStudent;extern Employee* employee;extern Student* student;// Human statement class Person {private: string name;// name string sex;// gender int age;// Age string status;// identity void init (); / initialization function public: void setPerson (); / / call initialization function void setStatus (string); / / set identity string getName (); / / get the person's name string getStatus () / / obtain the person's identity static void setP (int); / / currently add the number of person static void setRs (int); / / currently add the number of student static void setRe (int); / / currently add the number of employee static int getRe (); / / get Re static int getRs (); / / get Rs static int getP (); / / get p virtual void show (); / / virtual function} / / School class class school {private: / / add staff static bool addPerson (); / / delete staff static bool deletePerson (); / / query staff static Person queryPerson (); public: static bool getAdd (); static bool getDel (); static Person getQue (); / / Student class class Student: public Person {private: string StudentNumber; string StudentDormitory;public: / / constructor Student () / / > overload friend istream& operator > > (istream& I, Student& p); static int getTotal (); static void setTotal (int); string getStuId (); void show ();}; / / employee class class Employee: public Person {private: string EmployeeNumber; string EmployeeDormitory;public: Employee (); friend istream& operator > > (istream& I, Employee& p); static int getTotal (); static void setTotal (int); string getEpyId () The function declaration in the void show ();}; / / main function: void view (); bool doSwitch (char n); extern char nintacchar Cin ()

Remain.cpp file implementation header file

# include "Head.h" / / refer to the global variable int p = 0 maxEmployee s = 0 int e = 0 int Re = 0 int Rs = 0 int maxEmployee = 1000 int maxStudent = 1000 new Employee employee * employee = new Employee [maxEmployee]; Student* student = new Student [maxStudent]; char nterbank * Human * / / Human initialization function void Person::init () {cout name;cout sex; cout age;} / / void Person::setPerson () {init () } / / string Person::getName () {return name;} void Person::setP (int I) {p = p + I;} int Person::getP () {return p;} void Person::setStatus (string s) {status = s;} string Person::getStatus () {return status;} void Person::setRs (int j) {Rs = j;} void Person::setRe (int j) {Re = j } int Person::getRs () {return Rs;} int Person::getRe () {return Re;} / / Human show function void Person::show () {cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report