很显然,学习C++的最佳方法就是解决问题和进行实际操作,这里说的学习不只是学习其语言架构,还包括学习如何应用。在Stanley Lippman和Josee Lajoie所著的畅销书《C++ Primer(第三版)》中给也了许多习题,旨在帮助C++程序员获得实际经验,并能更深刻地理解这一语言的精髓。\r\n 但是,当你的学习进程由于其中某些难题而受阻时,你将如何是好?现在,你可以找开这本《C++ Primer题解》。这是和《C++ Primer》配套使用的,书中提供了《C++ Primer》中所有习题的解答,使你可以学会如何面对并解决程序设计上的挑战。拥有了这本题解,你就拥有了技术性详解、实用技巧和实际代码。它是失败感的终结者。有了这些解答,你的工作会更加顺利。
Foreword \r\nPreface \r\n1 Getting Started \r\n2 A Tour of C++ \r\n3 The C++ Data Types \r\n4 Expressions \r\n5 Statements \r\n6 Abstract Container Types \r\n7 Functions \r\n8 Scope and Lifetime \r\n9 Overloaded Functions \r\n10 Function Templates \r\n11 Exception Handling \r\n12 The Generic Algorithms \r\n13 Classes \r\n14 Class Initialization, Assignment, and Destruction \r\n15 Overloaded Operators and User-Defined Conversions \r\n16 Class Templates \r\n17 Class Inheritance and Subtyping \r\n18 Multiple and Virtual Inheritance \r\n19 Uses of Inheritance in C++ \r\n20 The iostream Library\r\nIndex
C++ has proven to be a popular programming language, and C++ Primer has proven to be just as popular among those wishing to learn the language. Learning a programming language, however, requires more than just reading about the language constructs. You must program, write your own code, and study code written by those who are more experienced with the use of the language.
To this end, Lippman and Lajoie (L&L) have provided exercises throughout C++ Primer to encourage their readers to test their understanding of the material. Our book provides the solutions to those exercises.
C++ Primer Answer Book is intended to be used in conjunction with C++ Primer. We assume that you have read the material in L&L preceding each exercise. We present our solution along with an explanation, but we do not repeat the material found in L&L. Only those concepts and constructs that have already been introduced are used in the solutions.
When the solution involves a complete program, we generally include the entire source code so that each solution stands on its own. All programs have been compiled using Microsoft Visual C++ Version 5.0. In some instances when the compiler did not meet the standard, a workaround was used and an explanation given.
We recommend that you use L&L to learn C++, work the exercises, and study the solutions presented here. We hope C++ Answer Book will aid you in understanding C++ while eliminating the frustration of being stuck without an answer to a problem.
Acknowledgments
Special thanks go to Stan Lippman and Josee Lajoie for having the faith to allow us to write this answer book and for their careful review of the text.
Sean Davey, Steve Edwards, S. Rollins Guild, Cay Horstmann, and Jeffrey Oldham provided many helpful comments on the manuscript.
Clovis thanks George Edmunds, Sam Hsu, Mohammad Ilyas, Mahesh Neelakanta, and Cyril Parkayi for their continued support; Sean Davey for the C++ review, for the IATEX macros, and for his technical support; Andrew Nathanson for his friendship and software/hardware support; S. Rollins Guild for the C++ review and his friendship; A. Carlos Tondo, Julia Mistrello, and Luiz and Elizabete T. Biavatti for helping our company succeed; and Caren E. Tondo for her love, patience, and sense of humor.
Bruce thanks Andrew Bellezza, Jodi Solomon, and Mary Walstrom for their friendship and encouragement; Zahira Ammarguellat, Luddy Harrison, Sandra Loosemore, and Cotton Seed -- one couldn't ask for better co-workers; and Misty and Buddy for their boundless patience.
Last, but certainly not least, we thank the staff at Addison-Wesley. We are especially grateful to our associate editor, Debbie Lafferty, for her patience and knowing when and how hard to push; the production editor, Maureen Willard, for guiding us through the editing, proofs, and final pages; the production manager, John Fuller, for getting the macros approved and improved early in the process; and the freelancer, Diane Freed, for assisting with the production of this book. We appreciate your kind help.