tailieunhanh - A Complete Guide to Programming in C++ part 44

A Complete Guide to Programming in C++ part 44. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | SOLUTIONS 409 inline void go_on cout n nGo on with return No previous input while n int menu Enter a command char askForSave Prompt user to save. char header n n Telephone List n n TelList myFriends A telephone list int main int action 0 string name Command Read a name while action Q action menu cls cout header endl switch action ----------------------------------------------------- case S case F case A case D unchanged refer to the solutions of chapter 16 . ----------------------------------------------------- case O To open a file if askForSave y if cout Telephone list read from file endl else cerr Telephone list not read endl go_on break case U Save as . if cout Telephone list has been saved in file endl else cerr Telephone list not saved endl go_on break 410 CHAPTER 18 FUNDAMENTALS OF FILE INPUT AND OUTPUT case W Save if cout Telephone list has been saved in the file endl else cerr Telephone list not saved endl go_on break case Q Quit if askForSave Y cls break End of while return 0 int menu static char menuStr . . . n ---------------------------------------- n O Open a file n W Save n U Save as . n ---------------------------------------- n Q Quit the program n n Your choice ------------------------------------------------------- everything else unchanged cf. solutions in Chapter 16 ------------------------------------------------------- return choice char askForSave char c cout Do you want to save the phone list y n do c c toupper c while c Y c N return c chapter 19 Overloading Operators Overloading operators allows you to apply existing operators to objects of class type. For example you can stipulate the effect of the operator for the objects of a par ticular class. This chapter describes various uses of overloaded operators. Arithmetic operators .

TỪ KHÓA LIÊN QUAN