Implementation requirements and programming points of the School Information Management System in the assignment of virtual functions

Source: Internet
Author: User

Question: there is a school information management system, which includes three aspects: teachers, students, and employees. A menu is used to perform operations on them. virtual functions are required.

1. Implementation requirements:

1) interface requirements:

A menu is displayed as follows before the operation:

==============================

School Information Management System

==============================

1. Display instructor Information

2. Display Student Information

3. Display employee information

4. display random personnel information

0. Exit the program

The user selects a number and the program displays the specified person information.

A random person is a type of random person.

2) Fault Tolerance requirements: prompt incorrect user input. You can exit the program only when you select to exit the program. After 1-4 functions are completed, you must re-display the menu to start the next operation. The simple console menu technology has been mentioned in the lesson. I will describe some articles in my blog. Click here to open the menu technology related articles.

2. programming highlights (TIPS)

1) Hierarchical Design Suggestions for classes: A person class can be abstracted from the above types, and the teacher (teacher) can be used as a special class for the worker (worker. To use a virtual function, all derivation uses public derivation.

2) design private data members of the current class in the class, such as the name, gender, and employee ID.

3) design the void disp () function for displaying the information of a person in the base class and use virtual modification. Override the virtual function in the derived class to display the private members in the current class.

4) In The DISP function of the derived class, you must use the base class and domain separator to specify the call base class's disp function, which is used to display the base class information first.

5) in the main function, you can generate a base class pointer array in advance to save the addresses of different types of derived class objects and establish a correspondence between the subscript of the array and the menu, in this way, you can use the user's choice to directly find the address of the derived class and then call the disp function to achieve polymorphism.

6) a random subscript (within the valid range) is generated by the random function during random selection to specify the address of the derived class object.

7) please refer to the relevant manual for the random Rand and random seeding functions used by the program.

8) You can use the system function to call the doscommand to implement the Screen Cleaning and pause functions used by the program.

3. For more information about the reference program, see the attachment (executable file. decompress it and execute it)

Attachment: virtualfun.7z

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.