服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - C/C++ - C++编写实现图书管理系统

C++编写实现图书管理系统

2022-10-20 13:17噙笑wink_ C/C++

这篇文章主要为大家详细介绍了C++编写实现图书管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

C++编写的一个图书管理系统,供大家参考,具体内容如下

2018大一的课设,搬到这纪念一下,共1200多行代码

为图书管理人员编写一个图书管理系统,图书管理系统的设计主要是实现对图书的管理和相关操作,包括3个表:
图书信息表——存储图书的基本信息,包括书号、书名、作者、出版社、出版日期、存馆数量、定价等。
读者信息表——存储读者的基本信息,包括学号、姓名、学院、专业班级等。
图书借阅表——存储读者借书的相关信息,包括学号、姓名、书号、书名、借阅日期、应还日期、归还日期等。

用菜单选择方式完成了以下功能:

1、图书信息添加功能:包括书号、书名、作者、出版社、出版日期、存馆数量、定价等。

2、图书信息查询:分别按书名, 按作者名,
按出版单位等进行查询。

3、图书信息排序:按书号、书名等按升序进行排序。

4、图书信息的修改、删除:按书号或书名进行图书的修改和删除。

5、读者信息添加功能:包括学号、姓名、学院、专业、班级等。

6、读者信息查询:分别按学号、姓名、班级等进行查询。

7、读者信息排序:按学号、学院等按升序进行排序。

8、读者信息的修改、删除:按学号+姓名进行读者信息的修改和删除

9、图书借阅:输入学号+书号,如果该书图书信息表中的存馆数量大于0,则可以借出,借出相应数量后修改图书信息表中的存馆数量,在图书借阅表添加该同学的借阅。

10、图书归还:输入学号+书号,修改图书信息表中的存馆数量,在图书借阅表中记录该同学的归还时间。

11、图书借阅查询:分别按学号、书名、学院等进行查询。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <windows.h>
#include <winbase.h>
const int INC=20;
using namespace std;
class Date{   //Date类 :日期类
public:
    int day;     //日
    int month;   //月
    int year;    //年
    Date(int d=1,int m=1,int y=2012){    //构造函数  默认初始日期2012.1.1
        //判断日期的合法性
        if(d>0&&d<32)day=d;else day=1;
        if(m>0&&m<13)month=m;else m=1;
        if(y>0)year=y;else year=2012;
    }
    void setDay(int d){day=d;}       //设置日
    void setMonth(int m){month=m;}   //设置月
    void setYear(int y){year=y;}     //年
    int getDay(){return day;}         //获取年月日
    int getMonth(){return month;}
    int getYear(){return year;}
    void disp(){cout<<year<<"/"<<month<<"/"<<day;}   //显示日期
    Date operator+(int dtmp);
    bool isLeapYear(int yy);              //判断是否为闰年
};
bool Date::isLeapYear(int yy){          //判断是否为闰年
    if(yy%400==0)
        return true;
    else if(yy%100!=0&&yy%4==0)
        return true;
    else return false;
}
 
Date Date::operator+(int dtmp){         //重载+运算符
    //bool Date::isLeapYear(int yy);
    int yy=year,mm=month,dd=day,mtmp,m2;     //年份yy   月份mm   日dd    借阅天数 dtmp
    bool flag;
    while(dtmp>=0)
    {
        if(isLeapYear(yy))
        {
            dtmp-=366;
            flag=true;
        }
        else
        {
            dtmp-=365;
            flag=false;
        }
        yy++;
    }
    if(flag)
        dtmp+=366;
    else dtmp+=365;
    yy--;
    if(isLeapYear(yy))
    {
        m2=29;
    }
    else
    {
        m2=28;
    }
    mtmp=dtmp+dd;
    int m_day[]={0,31,m2,31,30,31,30,31,31,30,31,30,31};   //每月天数
    for(;mtmp>m_day[mm];)
    {
        mtmp-=m_day[mm];
        if(mm==12)
        {
            mm=0;
            yy++;
        }
        mm++;
    }
    dd=mtmp;
    Date dt(yy,mm,dd);
    return dt;     //返回一个新日期
}
class Book{
//书号、书名、作者、出版社、出版日期、出版定价、存馆数量
private:
    string num;   //s书号
    string title;   //标题
    string author;   //作者
    string publisher;   //出版社
    Date publishdate;   //Date类:出版日期
    float price;   //价格
    int howmany;    //存馆数量
    public:
    Book(string num0="24416-5",string title0="数据结构",string author0="王红梅,胡明,王涛",
         string pub0="清华大学出版社",int bd=1,int bm=1,int by=2012,float pr=29.0,int ct=10):publishdate((bd,bm,by)){
    num=num0;title=title0;author=author0;publisher=pub0;price=pr;howmany=ct;}
    void setNum(string num0){num=num0;}      //设置书号
    void setTitle(string title0){title=title0;}   //设置标题
    void setAuthor(string author0){author=author0;}   //设置作者
    void setPublisher(string publisher0){publisher=publisher0;}   //设置出版社
    void setPublishdate(int bd,int bm,int by){Date d(bd,bm,by);publishdate=d;}    //设置出版日期,先构造在复制
    void setHowmany(int ct){howmany=ct;}    //设置库存
    void setPrice(float pr){price=pr;}   //设置价格
    string getNum(){return num;}        // 获取 书号 标题 作者 等信息
    string getTitle(){return title;}
    string getAuthor(){return author;}
    string getPublisher(){return publisher;}
    Date getPublishdate(){return publishdate;}
    int getHowmany(){return howmany;}
    float getPrice(){return price;}
    void dispABook(){
        cout <<num<< '\t'<<title<< '\t'<<author<< '\t'<<publisher<< '\t';       //获取Book信息  :书号标题  作者 出版社  日期
        getPublishdate().disp();    //获取日期信息
        cout<< '\t'<<price<< '\t'<<howmany << '\n' ;
        }
    friend class InBook;               //友元类
    friend class ReaderBorrowBook;
};
class Reader{
//学号、姓名、学院、专业班级  读者类
private:
    string num;    //学号
    string name;    //姓名
    string college;   //专业
    string classno;   //班级
public:
    Reader(string num0="20150000",string name0="NoName",string college0="信息学院",string clsn="网络工程15-1"){
    num=num0;name=name0;college=college0; classno=clsn;}         //构造函数初始化信息
    void setNum(string num0){num=num0;}            //功能函数 设置信息
    void setName(string name0){name=name0;}
    void setCollege(string college0){college=college0;}
    void setClassno(string clsn){classno=clsn;}
    string getNum(){return num;}   //功能函数   获取信息
    string getName(){return name;}
    string getCollege(){return college;}
    string getClassno(){return classno;}
    void dispAReader(){                    //显示信息
        cout <<num<< "\t"<<name<< "\t"<<college<< "\t"<<classno<< "\n";
    }
    friend class Inreader;
    friend class ReaderBorrowBook;
};
 
class BorrowBook
{                   //借阅的书类
private:
    string num;                //学号、姓名、书号、书名、借阅日期、应还日期、归还日期
    string name;
    string booknum;
    string title;
    Date borrowdate;
    Date toreturndate;
    Date returndate;
    BorrowBook(string num0="20150000",string name0="NoName",string booknum0="24416-5",
            string title0="数据结构",int bd=1,int bm=1,int by=2012,int td=1,int tm=5,int ty=2012,int rd=1,int rm=3,int ry=2012)
            :borrowdate(bd,bm,by),toreturndate(td,tm,ty),returndate(rd,rm,ry)
            {
                num=num0;name=name0; booknum=booknum0;title=title0;  //初始化
    }
    void setNum(string num0){num=num0;}  //设置学号
    void setName(string name0){name=name0;}//设置名字
    void setBookNum(string num0){booknum=num0;}//设置书号
    void setTitle(string title0){title=title0;}//书名
    void setBorrowdate(int bd,int bm,int by){Date d(bd,bm,by);borrowdate=d;}//借阅日期
    void setToreturndate(int td,int tm,int ty){Date d(td,tm,ty);toreturndate=d;}//
    void setReturndate(int rd,int rm,int ry){Date d(rd,rm,ry);returndate=d;}//归还日期
    string getNum(){return num;}   //获取学号
    string getName(){return name;}//获取名字
    string getBookNum(){return booknum;}//书号
    string getTitle(){return title;}//书名
    Date getBorrowdate(){return borrowdate;}//得到日期
    Date getReturndate(){return returndate;}
    Date getToreturndate(){return toreturndate;}
    void dispBorrowBook()     //显示值
    {
        cout <<num<< "\t"<<name<< "\t"<<booknum<< "\t"<<title<< "\t";
        borrowdate.disp();cout<<"\t";
        toreturndate.disp();cout<<"\t";
        returndate.disp();cout<< "\n";
    }
    friend class InBorrowBook;
    friend class ReaderBorrowBook;
 
};
void string2date(string pdates,int d[])
    {
        int k=0,by,bm,bd;
        while((pdates[k]<'0'||pdates[k]>'9')&&k<pdates.length())k++;
        by=0;
        for(;pdates[k]!='/'&&k<pdates.length();k++)
            by=by*10+pdates[k]-'0';
        k++;bm=0;
        for(;pdates[k]!='/'&&k<pdates.length();k++)
            bm=bm*10+pdates[k]-'0';
        if(pdates[k]=='/'){
          k++;bd=0;
          for(;k<pdates.length();k++)
            bd=bd*10+pdates[k]-'0';
            }
        else bd=1;
        d[0]=by;d[1]=bm;d[2]=bd;
    }
class InBook
{
    public:
    Book *book;    //book[n],很多本书
    int bookcount;     //记数
    void write2Bookfile()
    {
    string num,title,author,publisher,pdates;
    Date pdate;
    int i,bd,bm,by,ct;           //多余变量吧
    float price;
    ofstream outf( "d:\\book.txt", ios::out ) ;
    //写入的文件名应该与读出的文件名相同;调试时可以取不同的文件名,以免覆盖掉原文件
    if ( !outf )
      { cerr << "File could not be open." << endl ;  }
    outf<<"图书信息\n";
    for(int i=0;i<bookcount;i++)                 //写入图书信息
    {
        Date pd=book[i].getPublishdate();
        outf<<book[i].getNum()<< '\t'<<book[i].getTitle()<< '\t';
        outf<<book[i].getAuthor()<< '\t'<<book[i].getPublisher()<< '\t';
        outf<<pd.getYear()<<"/"<<pd.getMonth()<<"/"<<pd.getDay();
        outf<< '\t'<<book[i].getPrice()<< '\t'<<book[i].getHowmany()<< '\n' ;
    }
    outf.close() ;                 //关闭文件
    }
int inbookFile( char * fileName, int delLine)    //获取图书信息
{cout<<1<<endl;
    string num,title,author,publisher,pdates;
    Date pdate;
    int i,bd,bm,by,ct;
    float price;
    ifstream inf( fileName, ios::in ) ;
    if ( !inf )
      { cerr << "File could not be open." << endl ; return 1;   }
  char s[80];
  for ( i=1; i <= delLine; i++ )
      inf.getline( s, 80 ) ;
  i=0;
  while( !inf.eof() )//  { inf.getline( s, 80 ) ;    cout << s << endl ;  }
  {
      inf.getline( s, 80,'\t' ) ;//num=s;
      inf.getline( s, 80,'\t' ) ;title=s;
      inf.getline( s, 80,'\t' ) ;//author=s;
      inf.getline( s, 80,'\t' ) ;//publisher=s;
      inf.getline( s, 80,'\t' ) ;//pdates=s;
      inf>>price>>ct;
      if(title.length()>0)        i++;
      }
      bookcount=i;
      cout<<bookcount<<endl;
    inf.clear();
    inf.seekg(0,ios::beg);
    for ( i=1; i <= delLine; i++ )
      inf.getline( s, 80 ) ;
    book=new Book[bookcount+INC];
    for ( i=0; i <bookcount; i++ )
      {
      inf.getline( s, 80,'\t' ) ;num=s;
      inf.getline( s, 80,'\t' ) ;title=s;
      inf.getline( s, 80,'\t' ) ;author=s;
      inf.getline( s, 80,'\t' ) ;publisher=s;
      inf.getline( s, 80,'\t' ) ;pdates=s;
      inf>>price>>ct;//inf,getchar();
      if(title.length()>0){
        int d[3];
        if(num[0]==10)num=num.substr(1);
        string2date(pdates,d);
        by=d[0];bm=d[1];bd=d[2];
        book[i]=Book();
        book[i].setNum(num);
        book[i].setTitle(title);
        book[i].setAuthor(author);
        book[i].setPublisher(publisher);
        book[i].setPrice(price);
        book[i].setHowmany(ct);
        book[i].setPublishdate(bd,bm,by);
        }
      }
  inf.close() ;
  return bookcount;
  }
  friend class ReaderBorrowBook;
  int addbook(string num,string title,string author,string publisher,int bd,int bm,int by,float price,int ct)//添加图书信息
  {
        int i=bookcount;
        book[i]=Book();
        book[i].setNum(num);
        book[i].setTitle(title);
        book[i].setAuthor(author);
        book[i].setPublisher(publisher);
        book[i].setPrice(price);
        book[i].setHowmany(ct);
        book[i].setPublishdate(bd,bm,by);
        ++bookcount;
        return bookcount;
  }
    void searchbookbytitle(string title)         //按照书名查找
    {
        bool found=false;
        for(int i=0;i<bookcount;i++)
        if((book[i].getTitle()).find(title)!= string::npos) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            found=true;
            //return i;
            }
            if(!found)cout<<"book title:"<<title<<" not found."<<endl;
            //return -1;
    }
    int searchbookbytitlep(string title){    //精确查找
        for(int i=0;i<bookcount;i++)
        if(book[i].getTitle()==title) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            return i;
            }
            cout<<"book title:"<<title<<" not found."<<endl;
            return -1;
        }
    void searchbookbyauthor(string author)    //按照作者查找
    {
        bool found=false;
        for(int i=0;i<bookcount;i++)
        if((book[i].getAuthor()).find(author)!= string::npos) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            found=true;
            //return i;
            }
            if(!found)cout<<"book author:"<<author<<" not found."<<endl;
            //return -1;
    }
    int searchbookbyauthorp(string author) //精确查找
    {
        for(int i=0;i<bookcount;i++)
        if(book[i].getAuthor()==author) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            return i;
            }
            cout<<"book author:"<<author<<" not found."<<endl;
            return -1;
    }
    void searchbookbypub(string pub)    //按照出版社查找
    {
        bool found=false;
        for(int i=0;i<bookcount;i++)
        if((book[i].getPublisher()).find(pub)!= string::npos) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            found=true;
            //return i;
            }
        if(!found)cout<<"book publisher:"<<pub<<" not found."<<endl;
            //return -1;
    }
    int searchbookbypubp(string pub)
    {
        for(int i=0;i<bookcount;i++)
        if(book[i].getPublisher()==pub) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            return i;
            }
            return -1;
    }
    void searchbookbynum(string num)
    {//模糊查找包含num的串
        bool found=false;
        for(int i=0;i<bookcount;i++)
        if((book[i].getNum()).find(num)!= string::npos) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            found=true;
   //         return i;
            }
        if(!found)cout<<"book num:"<<num<<" not found."<<endl;
   //         return -1;
    }
    int searchbookbynump(string num)
    {//精确查找等于num的串
        for(int i=0;i<bookcount;i++)
        if((book[i].getNum())==num) {
            //cout<<book[i].getTitle()<< book[i].getTitle().find(title)<<endl;
            cout<<i<<"\t";
            book[i].dispABook();
            return i;
            }
            return -1;
    }
    void sortbookbynum()      //按照书号排序
    {
        for(int i=0;i<bookcount;i++){
            int k=i;
            for(int j=i+1;j<bookcount;j++)
                if(book[j].getNum()<book[k].getNum()) k=j;
            //cout<<k<<" k&i "<<i<<" :"<<book[i].getNum()<<"---"<<book[k].getNum()<<endl;
            if(k!=i){
                Book t=book[i];book[i]=book[k];book[k]=t;
                }
            }
    }
    void sortbookbytitle()     //按照标题排序
    {
        for(int i=0;i<bookcount;i++)
        {
            int k=i;
            for(int j=i+1;j<bookcount;j++)
                if(book[j].getTitle()<book[k].getTitle()) k=j;
            if(k!=i){
                Book t=book[i];book[i]=book[k];book[k]=t;
                }
        }
    }
    void changebookbynum(string oldnum,string newnum)     //按书号改信息
    {
        int k=searchbookbynump(oldnum);
        if(k>=0)    {
            book[k].setNum(newnum);
            cout<<"changebookbynum successed:"<<endl;
            book[k].dispABook();
        }
        else cout<<"changebook failed. No book of num="<<oldnum<<endl;
    }
    void deletebookbynum(string num)     //按书号删除书目
    {
        int k=searchbookbynump(num);
        if(k>=0)    {
            cout<<"Book to be deleted :"<<endl;
            book[k].dispABook();
            book[k]=book[bookcount-1];
            cout<<"deletebookbynum successed:"<<endl;
            bookcount--;
            //return bookcount;
        }
        else cout<<"deletebook  failed. No book of num="<<num<<endl;
    }
 
    void changebookbytitle(string oldtitle,string newtitle)
    {      //按标题修改书目
        int k=searchbookbytitlep(oldtitle);
        if(k>=0)    {
            book[k].setTitle(newtitle);
 
            cout<<"changebookbytitle successed:"<<endl;
            book[k].dispABook();
        }
        else cout<<"changebook failed. No book of id="codetool">

部分截图

C++编写实现图书管理系统

C++编写实现图书管理系统

C++编写实现图书管理系统

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/sxl_2018212698/article/details/110260115

延伸 · 阅读

精彩推荐
  • C/C++C++的函数与指针

    C++的函数与指针

    今天小编就为大家分享一篇关于C++函数与指针的文章,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧...

    uncle_ll6362022-02-16
  • C/C++C++ 程序员为什么看不起php程序员

    C++ 程序员为什么看不起php程序员

    由于当今市场状况,各种培训班飞起,PHPer越来越多,学习成本很低。导致了很多人对PHP的误解。其实PHP学到深入的时候,所需知识很多,并不是表面看到...

    codebay10402021-04-30
  • C/C++C++指向类成员函数的指针详细解析

    C++指向类成员函数的指针详细解析

    由于这几天在开发中要用到函数指针,所以就整理了一下关于函数指针的概念...

    C++教程网1592020-12-23
  • C/C++深入学习C语言中的函数指针和左右法则

    深入学习C语言中的函数指针和左右法则

    这篇文章主要介绍了深入学习C语言中的函数指针和左右法则,左右法则是一种常用的C指针声明,需要的朋友可以参考下...

    zinss269144732021-03-05
  • C/C++C语言16进制与ASCII字符相互转换

    C语言16进制与ASCII字符相互转换

    大家好,本篇文章主要讲的是C语言16进制与ASCII字符相互转换,感兴趣的同学赶快来看一看吧,对你有帮助的话记得收藏一下...

    冷冰难暖3822022-08-30
  • C/C++C++实现简单贪吃蛇游戏

    C++实现简单贪吃蛇游戏

    这篇文章主要为大家详细介绍了C++实现简单贪吃蛇游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...

    Johnny_Law7892021-06-22
  • C/C++递归删除二叉树中以x为根的子树

    递归删除二叉树中以x为根的子树

    今天小编就为大家分享一篇关于递归删除二叉树中以x为根的子树,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小...

    BLSxiaopanlaile7782021-07-24
  • C/C++Qt通过图片组绘制动态图片

    Qt通过图片组绘制动态图片

    这篇文章主要为大家详细介绍了Qt通过图片组绘制动态图片,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...

    weixin_457523043842021-09-15