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 write the code for C++ to realize the library management system

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

Share

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

This article mainly introduces the relevant knowledge of "how to write the code for C++ to implement the library management system". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "how to write the code for C++ to implement the library management system" can help you solve the problem.

General thought

To develop the library management system with C++, it is necessary to set up class for students and books respectively, and call the methods in class to realize the operations such as students logging in to borrow books, returning books, and librarians to view information.

Student.h

# pragma once#include#include#include#include#include#includeusing namespace std;class Student {private: int id; / / student's ID number int year; / / student's grade string name; string password; string gender; string telephone; string address; / / student's name, password, gender, telephone number and address vector book; vector grade / / student's books and their markspublic: Student (); ~ Student (); Student (int a, int b, string c, string d, string e, string f, string g); / / constructors int get_id (); int get_year (); string get_name (); string get_pass (); string get_gend (); string get_tele (); string get_addr (); vector get_book () / get the variables of class void change (int a, int b, string c, string d, string e, string f, string g); / / change the information void display (); / / display the information on the screen int length (); / / get the number of all students bool canopen (); / / check whether the file 'student.txt' can be opened void write () / / write the information current into file 'student.txt' void read (int n); / / read the information of the number n student from file' student.txt' void write_book (); / / write the books information of the student into file 'mybook.txt' void read_book () / / read the infomation of the student from file 'mybook.txt' void change_book (int a, int b); / / change the information of vector book and grade void add_book (int a); / / add a new book void display_book (); / / display the information of books on the screen void add_student (); / / add a student into the file' mybook.txt' void sub_student () / / subtract a student in the file 'mybook.txt' bool is_same_book (int a); / / check whether there exist a same book in the file' mybook.txt'}; Student::Student () {id = 0; year = 0; name = "not given"; password = "not given"; gender = "not given"; telephone = "not given"; address = "not given" / / define the default constructor} Student::~Student () {} Student::Student (int a, int b, string c, string d, string e, string f, string g) {id = a; year = b; name = c; password = d; gender = e; telephone = f; address = g; / / define the normal constructor} int Student::get_id () {return id } int Student::get_year () {return year;} string Student::get_name () {return name;} string Student::get_pass () {return password;} string Student::get_gend () {return gender;} string Student::get_tele () {return telephone;} string Student::get_addr () {return address;} vector Student::get_book () {return book } void Student::change (int a, int b, string c, string d, string e, string f, string g) {id = a; year = b; name = c; password = d; gender = e; telephone = f; address = g;} void Student::display () {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