Starting Out with C++ From Control Structures Through Objects
Ninth Edition
Starting Out with C++ From Control Structures Through Objects
Ninth Edition
Tony Gaddis
Haywood Community College
330 Hudson Street, New York, NY 10013
Senior Vice President Courseware Portfolio Management: Marcia J. Horton
Director, Portfolio Management: Engineering, Computer Science & Global Editions: Julian Partridge
Portfolio Manager: Matt Goldstein
Portfolio Management Assistant: Kristy Alaura
Field Marketing Manager: Demetrius Hall
Product Marketing Manager: Yvonne Vannatta
Managing Producer, ECS and Math: Scott Disanno
Content Producer: Sandra L. Rodriguez
Composition: iEnergizer Aptara, Ltd.
Cover Designer: Joyce Wells
Cover Photo: Samokhin/123RF
Credits and acknowledgments borrowed from other sources and reproduced, with permission, appear on the Credits page in the endmatter of this textbook.
Copyright 2018, 2015, 2012, 2009 Pearson Education, Inc. Hoboken, NJ 07030. All rights reserved. Manufactured in the United States of America. This publication is protected by copyright and permissions 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 otherwise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions department, please visit www.pearsoned.com/permissions/.
Many of the designations by manufacturers and seller 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 designations have been printed in initial caps or all caps.
The author and publisher of this book have used their best efforts in preparing this book. These efforts include the development, research, and testing of theories and programs to determine their effectiveness. The author and publisher make no warranty of any kind, expressed or implied, with regard to these programs or the documentation contained in this book. The author and publisher shall not be liable in any event for incidental or consequential damages with, or arising out of, the furnishing, performance, or use of these programs.
Pearson Education Ltd., London
Pearson Education Singapore, Pte. Ltd
Pearson Education Canada, Inc.
Pearson Education Japan
Pearson Education Australia PTY, Ltd
Pearson Education North Asia, Ltd., Hong Kong
Pearson Education de Mexico, S.A. de C.V.
Pearson Education Malaysia, Pte. Ltd.
Pearson Education, Inc., Hoboken
Library of Congress Cataloging-in-Publication Data
Names: Gaddis, Tony, author.
Title: Starting out with C++. From control structures through objects / Tony Gaddis, Haywood Community College.
Other titles: From control structures through objects | Starting out with C plus plus. From control structures through objects
Description: Ninth edition. | Boston : Pearson Education, Inc., [2017]
Identifiers: LCCN 2016056456 | ISBN 9780134498379 (alk. paper) | ISBN 0134498372 (alk. paper)
Subjects: LCSH: C++ (Computer program language)
Classification: LCC QA76.73.C153 G334 2017 | DDC 005.13/3dc23 LC record available at https://lccn.loc.gov/2016056456
1 17
ISBN-13: 978-0-13-449837-9
ISBN-10: 0-13-449837-2
Contents at a Glance
Online The following appendices are available at www.pearsonhighered.com/gaddis.
Appendix C: Introduction to Flowcharting
Appendix D: Using UML in Class Design
Appendix E: Namespaces
Appendix F: Passing Command Line Arguments
Appendix G: Binary Numbers and Bitwise Operations
Appendix H: STL Algorithms
Appendix I: Multi-Source File Programs
Appendix J: Stream Member Functions for Formatting
Appendix K: Unions
Appendix L: Answers to Checkpoints
Appendix M: Answers to Odd Numbered Review Questions
Case Study : String Manipulation
Case Study : High Adventure Travel AgencyPart 1
Case Study : Loan Amortization
Case Study : Creating a String Class
Case Study : High Adventure Travel AgencyPart 2
Case Study : High Adventure Travel AgencyPart 3
Case Study : Intersection of Sets
Case Study : Sales Commission
Contents
Online The following appendices are available at www.pearsonhighered.com/gaddis.
Appendix C: Introduction to Flowcharting
Appendix D: Using UML in Class Design
Appendix E: Namespaces
Appendix F: Passing Command Line Arguments
Appendix G: Binary Numbers and Bitwise Operations
Appendix H: STL Algorithms
Appendix I: Multi-Source File Programs
Appendix J: Stream Member Functions for Formatting
Appendix K: Unions
Appendix L: Answers to Checkpoints
Appendix M: Answers to Odd Numbered Review Questions
Case Study : String Manipulation
Case Study : High Adventure Travel AgencyPart 1
Case Study : Loan Amortization
Case Study : Creating a String Class
Case Study : High Adventure Travel AgencyPart 2
Case Study : High Adventure Travel AgencyPart 3
Case Study : Intersection of Sets
Case Study : Sales Commission
Location of Videonotes in the Text
Preface
Welcome to Starting Out with C++: From Control Structures through Objects, 9th edition. This book is intended for use in a two-semester C++ programming sequence, or an accelerated one-semester course. Students new to programming, as well as those with prior course work in other languages, will find this text beneficial. The fundamentals of programming are covered for the novice, while the details, pitfalls, and nuances of the C++ language are explored in depth for both the beginner and more experienced student. The book is written with clear, easy-to-understand language, and it covers all the necessary topics for an introductory programming course. This text is rich in example programs that are concise, practical, and real-world oriented, ensuring that the student not only learns how to implement the features and constructs of C++, but why and when to use them.
Changes in the Ninth Edition
This books pedagogy, organization, and clear writing style remain the same as in the previous edition. Many improvements and updates have been made, which are summarized here:
Next page