Thứ Hai, 17 tháng 3, 2014

Tài liệu ABSOLUTE C++ doc


LINK DOWNLOAD MIỄN PHÍ TÀI LIỆU "Tài liệu ABSOLUTE C++ doc": http://123doc.vn/document/1038613-tai-lieu-absolute-c-doc.htm


Walter Savitch
University of California, San Diego
Contributor
Kenrick Mock
University of Alaska Anchorage


ABSOLUTE
C++
Boston Columbus Indianapolis New York San Francisco Upper Saddle River
Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montréal Toronto
Delhi Mexico City São Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
5th Edition
This book was composed in InDesign. Basal font is Adobe Garamond 10/12. Display font is Optima LT Std.
Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook
appear on the appropriate page within text.
Copyright © 2013, 2010, 2008, 2006, 2004 by Pearson Education, Inc., publishing as Addison-Wesley. All
rights reserved. Manufactured in the United States of America. This publication is protected by Copyright, and
permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or
likewise. To obtain permission(s) to use material from this work, please submit a written request to Pearson
Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you
may fax your request to 201-236-3290.
Many of the designations by manufacturers and sellers to distinguish their products are claimed as trademarks.
Where those designations appear in this book, and the publisher was aware of a trademark claim, the designa-
tions have been printed in initial caps or all caps.
Library of Congress Cataloging-in-Publication Data
Savitch, Walter J.
Absolute C++ / Walter Savitch ; contributor, Kenrick Mock. 5th ed.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-13-283071-3 (alk. paper)
1. C++ (Computer program language) I. Mock, Kenrick. II. Title.
QA76.73.C153S279 2010
005.13’3 dc23
2012001325
1 2 3 4 5 6 7 8 9 10—EB—15 14 13 12
ISBN-10: 0-13-283071-X
ISBN-13: 978-0-13-283071-3
Vice President and Editorial Director, ECS:
Marcia Horton
Executive Editor: Matt Goldstein
Editorial Assistants: Chelsea Kharakozova/
Emma Snider
Vice President Marketing: Patrice Jones
Marketing Manager: Yez Alayan
Marketing Coordinator: Kathryn Ferranti
Vice President and Director of Production:
Vince O’Brien
Managing Editor: Jeff Holcomb
Senior Production Project Manager: Marilyn Lloyd
Manufacturing Manager: Nick Skilitis
Operations Specialist: Lisa McDowell
Text Designer: Joyce Cosentino Wells
Cover Designer: Anthony Gemmellaro
Cover Image: © Shutterstock
Media Editor: Dan Sandin
Manager, Rights and Permissions: Michael Joyce
Text Permissions—assessment: Dana Weightman
Text Permissions—clearance: Nicole Coffi neau/
Creative Compliance
Full-Service Vendor: GEX Publishing Services
Project Management: GEX Publishing Services
Printer/Binder: Edwards Brothers
Cover Printer: Lehigh-Phoenix Color
www.itpub.net
This book is designed to be a textbook and reference for programming in the C++ language.
Although it does include programming techniques, it is organized around the features of the
C++ language, rather than any particular curriculum of techniques. The main audience I had
in mind is undergraduate students who had not had extensive programming experience with
the C++ language. As such, this book is a suitable C++ text or reference for a wide range of
users. The introductory chapters are written at a level that is accessible to beginners, while the
boxed sections of those chapters serve to introduce more experienced programmers to basic
C++ syntax. Later chapters are also understandable to beginners, but are written at a level
suitable for students who have progressed to these more advanced topics. Absolute C++ is also
suitable for anyone learning the C++ language on their own. (For those who want a textbook
with more pedagogical material and more on very basic programming technique, try my text
Problem Solving with C++ , Eighth Edition, Pearson Education.)
The C++ coverage in this book goes well beyond what a beginner needs to know. In
particular, it has extensive coverage of inheritance, polymorphism, exception handling,
and the Standard Template Library (STL), as well as basic coverage of patterns and the
unified modeling language (UML).
CHANGES IN THIS EDITION
This fifth edition presents the same programming philosophy as the fourth edition. For
instructors, you can teach the same course, presenting the same topics in the same order
with no changes in the material covered or the chapters assigned. Changes include:
■ Chapter 1 now includes a short introduction to the string class and Chapter 2 includes
a short introduction to reading data from a text file. Together, this material allows
instructors to present students with problems of larger scale and real-world applicability
as early as Chapter 2.
■ Chapter 12 now includes a section on using stringstream to convert between
strings and other data types.
■ Chapter 13 briefly describes tail recursion and gives an example of mutual recursion.
■ Ten new self-test exercises have been added along with twenty-five new Programming
Projects. By request, some of these are longer and less prescriptive projects that give
the student more practice designing programming solutions.
■ Several errors that were found in the fourth edition have been corrected.
■ Fifteen new VideoNotes have been added to the book’s website (www.pearsonhighered.
com/savitch) for a total of forty-six videos. These VideoNotes walk students through the
process of problem solving and coding to reinforce key programming concepts. An icon
appears in the margin of the book when a video is available regarding the corresponding
topic in the text.
ANSI/ISO C++ STANDARD
This edition is fully compatible with compilers that meet the latest ANSI/ISO C++
standard.
Preface
v
vi Preface
STANDARD TEMPLATE LIBRARY
The Standard Template Library (STL) is an extensive collection of preprogrammed
data structure classes and algorithms. The STL is perhaps as big a topic as the core C++
language, so I have included a substantial introduction to STL. There is a full chapter
on the general topic of templates and a full chapter on the particulars of STL, as well as
other material on, or related to, STL at other points in the text.
OBJECT-ORIENTED PROGRAMMING
This book is organized around the structure of C++. As such, the early chapters cover
aspects of C++ that are common to most high-level programming languages but are
not particularly oriented toward object-oriented programming (OOP). For a reference
book—and for a book for learning a second language—this makes sense. However,
I consider C++ to be an OOP language. If you are programming in C++ and not C,
you must be using the OOP features of C++. This text offers extensive coverage
of encapsulation, inheritance, and polymorphism as realized in the C++ language.
Chapter 20 , on patterns and UML, gives additional coverage of OOP-related material.
FLEXIBILITY IN TOPIC ORDERING
This book allows instructors wide latitude in reordering the material. This is important
if a book is to serve as a reference. This is also in keeping with my philosophy of
accommodating the instructor’s style, rather than tying the instructor to my own
personal preference of topic ordering. Each chapter introduction explains what material
must already have been covered before each section of the chapter can be covered.
ACCESSIBLE TO STUDENTS
It is not enough for a book to present the right topics in the right order. It is not
even enough for it be correct and clear to an instructor. The material also needs to
be presented in a way that is accessible to the novice. Like my other textbooks, which
proved to be very popular with students, this book was written to be friendly and
accessible to the student.
SUMMARY BOXES
Each major point is summarized in a boxed section. These boxed sections are spread
throughout each chapter. They serve as summaries of the material, as a quick reference
source, and as a quick way to learn the C++ syntax for a feature you know about in
general but for which you do not know the C++ particulars.
SELF-TEST EXERCISES
Each chapter contains numerous self-test exercises. Complete answers for all the self-
test exercises are given at the end of each chapter.
www.itpub.net
Preface vii
VIDEO NOTES
VideoNotes are step-by-step videos that guide readers through the solution to an end
of chapter problem or further illuminate a concept presented in the text. Icons in the
text indicate where a VideoNote enhances a topic. Fully navigable problems allow for
self-paced instruction. VideoNotes are located at www.pearsonhighered.com/savitch.
OTHER FEATURES
Pitfall sections, programming technique sections, and examples of complete programs
with sample input and output are given throughout each chapter. Each chapter ends
with a summary and a collection of programming projects.
ONLINE PRACTICE AND ASSESSMENT WITH
MyProgrammingLab
MyProgrammingLab helps students fully grasp the logic, semantics, and syntax of
programming. Through practice exercises and immediate, personalized feedback,
MyProgrammingLab improves the programming competence of beginning students
who often struggle with the basic concepts and paradigms of popular high-level
programming languages.
A self-study and homework tool, a MyProgrammingLab course consists of hundreds
of small practice problems organized around the structure of this textbook. For
students, the system automatically detects errors in the logic and syntax of their code
submissions and offers targeted hints that enable students to figure out what went
wrong—and why. For instructors, a comprehensive gradebook tracks correct and
incorrect answers and stores the code inputted by students for review.
MyProgrammingLab is offered to users of this book in partnership with Turing’s
Craft, the makers of the CodeLab interactive programming exercise system. For a full
demonstration, to see feedback from instructors and students, or to get started using
MyProgrammingLab in your course, visit www.myprogramminglab.com.
SUPPORT MATERIAL
The following support materials are available to all users of this book at
www.pearsonhighered.com/cssupport:
■ Source code from the book
The following resources are available to qualified instructors only at www.
pearsonhighered.com/irc. Please contact your local sales representative for access
information.
■ Instructor’s Manual with Solutions
■ PowerPoint
®
slides
VideoNote
viii Preface
ACKNOWLEDGMENTS
Numerous individuals have contributed invaluable help and support to making this
book happen. Frank Ruggirello and Susan Hartman at Addison-Wesley first conceived
the idea and supported the first edition, for which I owe them a debt of gratitude.
A special thanks to Matt Goldstein who was the editor for the second, third, and
fourth editions. His help and support were critical to making this project succeed.
Chelsea Kharakozova, Marilyn Lloyd, Yez Alayan, and the other fine people at Pearson
Education also provided valuable support and encouragement.
The following reviewers provided suggestions for the book. I thank them all for
their hard work and helpful comments.
Richard Albright University of Delaware
J. Boyd Trolinger Butte College
Jerry K. Bilbrey, Jr Francis Marion University
Albert M. K. Cheng University of Houston
David Cherba Michigan State University
Fredrick H. Colclough Colorado Technical University
Drue Coles Boston University
Stephen Corbesero Moravian College
Christopher E. Cramer
Ron DiNapoli Cornell University
Qin Ding Pennsylvania State University, Harrisburg
Martin Dulberg North Carolina State University
H. E. Dunsmore Purdue University
Evan Golub University of Maryland
Terry Harvey University of Delaware
Joanna Klukowska Hunter College, CUNY
Lawrence S. Kroll San Francisco State University
Stephen P. Leach Florida State University
Alvin S. Lim Auburn University
Tim H. Lin Cal Poly Pomona
R. M. Lowe Clemson University
Jeffrey L. Popyack Drexel University
Amar Raheja Cal Poly Pomona
Victoria Rayskin University of Central Los Angeles
Loren Rhodes Juniata College
Jeff Ringenberg University of Michigan
www.itpub.net
Preface ix
Victor Shtern Boston University
Aaron Striegel University of Notre Dame
J. Boyd Trolinger Butte College
Chrysafis Vogiatzis University of Florida
Joel Weinstein Northeastern University
Dick Whalen College of Southern Maryland
A special thanks goes to Kenrick Mock (University of Alaska Anchorage) who
executed the updating of this edition. He once again had the difficult job of satisfying
me, the editor, and himself. I thank him for a truly excellent job.
Walter Savitch
LOCATION OF VIDEONOTES IN THE TEXT
www.pearsonhighered.com/savitch
Chapter 1 Compiling and Running a C++ Program, page 4
Solution to Programming Project 1.11, page 44
Chapter 2 Nested Loop Example, page 83
Solution to Programming Project 2.5, page 95
Solution to Programming Project 2.9, page 96
Solution to Programming Project 2.10, page 96
Chapter 3 Generating Random Numbers, page 107
Scope Walkthrough, page 125
Solution to Programming Project 3.9, page 140
Chapter 4 Using an Integrated Debugger, page 173
Solution to Programming Project 4.4, page 180
Solution to Programming Project 4.11, page 181
Chapter 5 Array Walkthrough, page 187
Solution to Programming Project 5.7, page 233
Solution to Programming Project 5.15, page 237
Chapter 6 Solution to Programming Project 6.5, page 272
Solution to Programming Project 6.9, page 273
Chapter 7 Constructor Walkthrough, page 276
Solution to Programming Project 7.4, page 316
Solution to Programming Project 7.7, page 317
Chapter 8 Solution to Programming Project 8.7, page 366
Chapter 9 Using
cin and getline with the string class, page 399
Solution to Programming Project 9.11, page 417
Solution to Programming Project 9.13, page 418
Chapter 10 Example of Shallow Copy vs. Deep Copy, page 459
Solution to Programming Project 10.5, page 469
Chapter 11 Avoiding Multiple De nitions with
#ifndef, page 484
Solution to Programming Project 11.5, page 512
Chapter 12 Walkthrough of the stringstream demo, page 554
Solution to Programming Project 12.17, page 566
Solution to Programming Project 12.25, page 570
Chapter 13 Recursion and the Stack, page 582
Walkthrough of Mutual Recursion, page 591
Solution to Programming Project 13.9, page 609
Solution to Programming Project 13.11, page 610
Chapter 14 Solution to Programming Project 14.7, page 657
VideoNote
www.itpub.net
Chapter 15 Solution to Programming Project 15.5, page 689
Solution to Programming Project 15.7, page 690
Chapter 16 Solution to Programming Project 16.3, page 728
Solution to Programming Project 16.7, page 729
Chapter 17 Solution to Programming Project 17.5, page 820
Solution to Programming Project 17.11, page 822
Chapter 18 Solution to Programming Project 18.5, page 854
Chapter 19 Solution to Programming Project 19.9, page 909
Solution to Programming Project 19.12, page 911
Chapter 20 Solution to Programming Project 20.6, page 931
This page intentionally left blank
www.itpub.net

Không có nhận xét nào:

Đăng nhận xét