C plus plus how to program paul deitel kho tài liệu bách khoa

1.1K 173 0
C plus plus how to program paul deitel kho tài liệu bách khoa

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ONLINE ACCESS Thank you for purchasing a new copy of C++ How to Program, Ninth Edition Your textbook includes twelve months of prepaid access to the book’s Companion Website This prepaid subscription provides you with full access to the following student support areas: • VideoNotes are step-by-step video tutorials specifically designed to enhance the programming concepts presented in this textbook • Premium Web Chapters and Appendices • Source Code Continued from Back Cover ❝ It’s great that the text introduces object-oriented programming early The car analogy was well-thought out Meticulous treatment of control structures The virtual function figure and corresponding explanation in the Polymorphism chapter is thorough and truly commendable.~ —Gregory Dai, eBay ❝ The example-driven presentation is enriched by the optional OO design case study that contextualizes the material in a software engineering project.~ —Gavin Osborne, Saskatchewan Institute of Applied Science and Technology ❝ The Object-Oriented Programming: Inheritance chapter is well done Excellent introduction to polymorphism.~ —David Topham, Ohlone College ❝ The overview of computing is about the right depth and breadth for an intro course.~ —Robert C Seacord, Secure Coding Manager at SEI/CERT, author of Secure Coding in C and C++ ❝ Thorough and detailed coverage of exceptions from an object-oriented point of view.~ —Dean Mathias, Utah State University ❝ Introducing the UML early is a great idea.~ —Raymond Stephenson, Microsoft ❝ Good use of diagrams, especially of the activation call stack and recursive functions.~ —Amar Raheja, California State Polytechnic University, Pomona ❝ Terrific discussion of pointers—the best I have seen.~ —Anne B Horton, Lockheed Martin Use a coin to scratch off the coating and reveal your student access code Do not use a knife or other sharp object as it may damage the code To access the C++ How to Program, Ninth Edition, Companion Website for the first time, you will need to register online using a computer with an Internet connection and a web browser The process takes just a couple of minutes and only needs to be completed once Go to http://www.pearsonhighered.com/deitel/ Click on Companion Website Click on the Register button On the registration page, enter your student access code* found beneath the scratch-off panel Do not type the dashes You can use lower- or uppercase Follow the on-screen instructions If you need help at any time during the online registration process, simply click the Need Help? icon Once your personal Login Name and Password are confirmed, you can begin using the C++ How to Program Companion Website! To log in after you have registered: You only need to register for this Companion Website once After that, you can log in any time at http://www.pearsonhighered.com/deitel/ by providing your Login Name and Password when prompted *Important: The access code can only be used once This subscription is valid for twelve months upon activation and is not transferable If this access code has already been revealed, it may no longer be valid If this is the case, you can purchase a subscription by going to http:// www.pearsonhighered.com/deitel/ and following the on-screen instructions ❝ I especially value the code examples and diagrams Great coverage of OOP Nice detail in [Intro to Classes]—students can learn so much from it; I love that every line of code is explained and that UML class diagrams are given I really like the Structured Programming Summary Good visuals provided for what’s going on in memory [for pass-by-value and pass-by-reference] The [Inheritance] examples nicely reinforce the concepts I love the description of [a possible] polymorphic video game.~ —Linda M Krause, Elmhurst College ❝A good whirlwind tour [in Chapter 1] of what computers are, the history of the computer industry and some high-level introductory material on C++ [Chapter 2] is a gentle introduction to C++ that gradually gets soon-to-be programmers learning just enough to be able to interesting things right away The [Chapter 3, Introduction to Classes, Objects and Strings] examples are solid.~—Dean Michael Berris, Google ❝A good control statements chapter; the discussions of increment ops, {} initialization and floating point data formatting are excellent; novices will benefit from these sections The discussion about stack memory, storage classes and the function call mechanism is great I enjoyed the recursion section The pointers and arrays chapter manages to explain something that’s quite difficult to teach: the elusive nature of pointers [Classes: A Deeper Look; Throwing Exceptions] is good and well-focused The operator overloading chapter explains the topic clearly and builds a convincing, realistic class [Array] that demonstrates the capabilities of OOD and C++ [Inheritance] is short, to the point and very clear [Standard Library Containers] is excellent, up to date, accurate, concise and readable; I really enjoyed it.~ —Danny Kalev, C++ expert, Certified System Analyst and former member of C++ Standards Committee ❝Clearly explains control structures The [Functions] code examples exemplify the chapter content; the discussion was very good and the exer- cises had good variation in difficulty [Arrays and Vectors] was really good; I like the idea of std::array [instead of built-in arrays] by default [Exception Handling] was short, sweet, to the point and accurate.~ —James McNellis, Microsoft ❝An accurate and complete C++ book that everybody can understand A ‘must-have.’ Novices and advanced programmers will find this book an excellent tool for learning C++ Really fun and interesting exercises (Knight’s Tour, Eight Queens, etc.) Easy-to-understand string examples and interesting exercises I especially liked the Quicksort explanation The Simpletron exercises are brilliant.~ —José Antonio González Seco, Parliament of Andalusia ❝I really like the Making a Difference exercises The [dice and card games] get students excited.~ —Virginia Bailey, Jackson State University ❝Provides a complete basis of fundamental instruction in all core aspects of C++ A solid overview of Stream I/O.~ —Peter DePasquale, The College of New Jersey ❝Great coverage of polymorphism and how the compiler implements polymorphism ‘under the hood.’~ —Ed James-Beckham, Borland ❝A nice introduction to searching and sorting, and Big-O.~ —Robert Myers, Florida State University ❝Will get you up and running quickly with the [smart pointers] and regular expression libraries.~ —Ed Brey, Kohler Co ❝The most thorough C++ treatment I’ve seen Replete with real-world case studies covering the full software development lifecycle Code examples are extraordinary!~—Terrell Hull, Logicalis Integration Solutions Deitel® Series Page How To Program Series Android How to Program C How to Program, 7/E C++ How to Program, 9/E C++ How to Program, Late Objects Version, 7/E Java™ How to Program, 9/E Java™ How to Program, Late Objects Version, 8/E Internet & World Wide Web How to Program, 5/E Visual Basic® 2012 How to Program Visual C#® 2012 How to Program, 3/E Visual C++® 2008 How to Program, 2/E Small Java™ How to Program, 6/E Small C++ How to Program, 5/E Simply Series Simply C++: An App-Driven Tutorial Approach Simply Java™ Programming: An App-Driven Tutorial Approach Simply Visual Basic® 2010, 4/E: An App-Driven Tutorial Approach CourseSmart Web Books www.deitel.com/books/CourseSmart/ C++ How to Program, 7/E, 8/E & 8/E Simply C++: An App-Driven Tutorial Approach Java™ How to Program, 7/E, 8/E & 9/E Simply Visual Basic 2010: An App-Driven Approach, 4/E Visual Basic® 2012 How to Program Visual Basic® 2010 How to Program Visual C#® 2012 How to Program, 5/E Visual C#® 2010 How to Program, 4/E Deitel® Developer Series C++ for Programmers, 2/E Android for Programmers: An App-Driven Approach C# 2010 for Programmers, 3/E Dive Into® iOS 6: An App-Driven Approach iOS for Programmers: An App-Driven Approach Java™ for Programmers, 2/E JavaScript for Programmers LiveLessons Video Learning Products www.deitel.com/books/LiveLessons/ Android® App Development Fundamentals C++ Fundamentals C# Fundamentals iOS App Development Fundamentals Java™ Fundamentals JavaScript Fundamentals Visual Basic Fundamentals To receive updates on Deitel publications, Resource Centers, training courses, partner offers and more, please register for the free Deitel® Buzz Online e-mail newsletter at: www.deitel.com/newsletter/subscribe.html and join the Deitel communities on Twitter® @deitel Facebook® facebook.com/DeitelFan and Google+ gplus.to/deitel To communicate with the authors, send e-mail to: deitel@deitel.com For information on government and corporate Dive-Into® Series on-site seminars offered by Deitel & Associates, Inc worldwide, visit: www.deitel.com/training/ or write to deitel@deitel.com For continuing updates on Prentice Hall/Deitel publications visit: www.deitel.com www.pearsonhighered.com/deitel/ Visit the Deitel Resource Centers that will help you master programming languages, software development, Android and iPhone/iPad app development, and Internet- and web-related topics: www.deitel.com/ResourceCenters.html cpphtp9_titlepages.fm Page iii Friday, January 4, 2013 6:37 AM Paul Deitel Deitel & Associates, Inc Harvey Deitel Deitel & Associates, Inc Vice President and Editorial Director: Marcia J Horton Executive Editor: Tracy Johnson Associate Editor: Carole Snyder Director of Marketing: Christy Lesko Marketing Manager: Yezan Alayan Marketing Assistant: Jon Bryant Director of Production: Erin Gregg Managing Editor: Scott Disanno Associate Managing Editor: Robert Engelhardt Operations Specialist: Lisa McDowell Art Director: Anthony Gemmellaro Cover Design: Abbey S Deitel, Harvey M Deitel, Anthony Gemmellaro Cover Photo Credit: © Shutterstock/Sean Gladwell Media Project Manager: Renata Butera Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook appear on page vi The authors and publisher of this book have used their best efforts in preparing this book These efforts include the development, research, and testing of the theories and programs to determine their effectiveness The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in this book The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs Copyright © 2014, 2012, 2010 Pearson Education, Inc., publishing as Prentice Hall 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., 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 designations have been printed in initial caps or all caps Library of Congress Cataloging-in-Publication Data on file 10 ISBN-10: 0-13-337871-3 ISBN-13: 978-0-13-337871-9 In memory of Dennis Ritchie, creator of the C programming language— one of the key languages that inspired C++ Paul and Harvey Deitel Trademarks DEITEL, the double-thumbs-up bug and DIVE INTO are registered trademarks of Deitel and Associates, Inc Carnegie Mellon Software Engineering Institute™ is a trademark of Carnegie Mellon University CERT® is registered in the U.S Patent and Trademark Office by Carnegie Mellon University Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A and other countries Screen shots and icons reprinted with permission from the Microsoft Corporation This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation UNIX is a registered trademark of The Open Group Throughout this book, trademarks are used Rather than put a trademark symbol in every occurrence of a trademarked name, we state that we are using the names in an editorial fashion only and to the benefit of the trademark owner, with no intention of infringement of the trademark Contents Chapters 24–26 and Appendices F–K are PDF documents posted online at the book’s Companion Website, which is accessible from www.pearsonhighered.com/deitel Preface 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 2.1 Introduction to Computers and C++ xxi Introduction Computers and the Internet in Industry and Research Hardware and Software 1.3.1 Moore’s Law 1.3.2 Computer Organization Data Hierarchy Machine Languages, Assembly Languages and High-Level Languages C++ Programming Languages Introduction to Object Technology Typical C++ Development Environment Test-Driving a C++ Application Operating Systems 1.11.1 Windows—A Proprietary Operating System 1.11.2 Linux—An Open-Source Operating System 1.11.3 Apple’s OS X; Apple’s iOS for iPhone®, iPad® and iPod Touch® Devices 1.11.4 Google’s Android The Internet and World Wide Web Some Key Software Development Terminology C++11 and the Open Source Boost Libraries Keeping Up to Date with Information Technologies Web Resources Introduction to C++ Programming; Input/Output and Operators Introduction 2 6 10 11 14 17 19 25 25 26 26 27 27 29 31 32 33 38 39 viii Contents 2.2 2.3 2.4 2.5 2.6 2.7 2.8 First Program in C++: Printing a Line of Text Modifying Our First C++ Program Another C++ Program: Adding Integers Memory Concepts Arithmetic Decision Making: Equality and Relational Operators Wrap-Up Introduction to Classes, Objects and Strings 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 Introduction Defining a Class with a Member Function Defining a Member Function with a Parameter Data Members, set Member Functions and get Member Functions Initializing Objects with Constructors Placing a Class in a Separate File for Reusability Separating Interface from Implementation Validating Data with set Functions Wrap-Up Control Statements: Part 1; Assignment, ++ and Operators 39 43 44 48 49 53 57 66 67 67 70 74 79 83 87 92 97 104 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 4.13 Introduction Algorithms Pseudocode Control Structures if Selection Statement if…else Double-Selection Statement while Repetition Statement Formulating Algorithms: Counter-Controlled Repetition Formulating Algorithms: Sentinel-Controlled Repetition Formulating Algorithms: Nested Control Statements Assignment Operators Increment and Decrement Operators Wrap-Up Control Statements: Part 2; Logical Operators 157 5.1 5.2 5.3 Introduction Essentials of Counter-Controlled Repetition for Repetition Statement 105 105 106 107 110 112 116 118 124 134 139 140 143 158 158 159 %  % *0"*"*  %/  %  .4&- %( %(& *0")" &%( %( *0")"* ( %( *0")") % %(  +%&, ( (! 4& %                              4&" ,'!/,!    F ,1J3/J @  F ?0,1,1) K* F* ?  J/I 6? & ??  F3 @ F*    %7 ,@ 5? @+ 1F ,1 F* F 1 ,& @3 &,1,1) F* J/I >@ /3F,318 K3 535I/? @ ?* /)3?,F*0@ ? F* @,05/  !  6 F,31 HO8H847 1 F* &@F ? IF 03? 305/ L  ) !  6 F,31 HO8H8H78 ! 5/ @ F ,1 @ 1,1) 3?  @ 1,1) 3? ? @  31 31 3? 03? ! %8  /,@F 3& 10 @ 3I/  @3?F  /5* F,//M 1 3I1F@ 3I/  @3?F  M 3I1F 1I0 ? 05/3M 5M?3// ? 3?@ 3I/  @3?F  M @3,/ @ I?,FM 1I0 ? 1 @3 318 3I>// / ?1 3IF ! # ! # 6 F,31 HO8G847 ! # ! # 6 F,31 HO8G8H7 1 F* 03? &&,, 1F IF 03? 305/ L   ! # 6 F,31 HO8G8G78 ,)I? HO84 @I00?,N @ F* @ ?*,1) 1 @3?F,1) /)3?,F*0@ ,@I@@  ,1 F* 33.>@ L05/ @ 1 L ?,@ @8 *,@ *5F ? /@3 ,1F?3I @   ! ! K*,* ,@ I@  F3 *?F ?,N 1 /)3?,F*0>@ K3?@F+ @ ?I1F,0 #F*F ,@ *3K *? 1 /)3?,F*0 0M *J F3 K3? F3 @3/J  5?3/ 08      #! ,1 ? @ ?* ,1?M @ ?*  I?@,J /,1 ? @ ?*  I?@,J ,1?M @ ?* ,1?M F? @ ?* ,1 ? @ ?* 6/,1  /,@F7 $%&!"#'()!"*+ @F1? /,??M &I1F,31    F,31 HO8H84  F,31 HO8H8H L ?,@ HO8! L ?,@ HO82  F,31 428C L ?,@ 428H4  F,31 4C8G8C    #  #! 1@ ?F,31 @3?F  / F,31 @3?F  I?@,J ?) @3?F I/ @3?F I F @3?F  I?@,J :I,.@3?F ,1?M F? @3?F (,"- @F1? /,??M &I1F,31  5 @3?F    F,31 HO8G84  F,31 HO8G8H  F,31 HO8G8G L ?,@ @ HO8'$HO8C L ?,@ HO8B L ?,@ HO84O  F,31 428C  F,31 4C8G8C  F,31 4C8G84H & 4&"   ... 6:37 AM Paul Deitel Deitel & Associates, Inc Harvey Deitel Deitel & Associates, Inc Vice President and Editorial Director: Marcia J Horton Executive Editor: Tracy Johnson Associate Editor: Carole... Time Class Case Study Class Scope and Accessing Class Members Access Functions and Utility Functions Time Class Case Study: Constructors with Default Arguments Destructors When Constructors and... lifecycle Code examples are extraordinary!~—Terrell Hull, Logicalis Integration Solutions Deitel Series Page How To Program Series Android How to Program C How to Program, 7/E C+ + How to Program,

Ngày đăng: 16/11/2019, 21:00

Từ khóa liên quan

Mục lục

  • Cover

  • Title Page

  • Copyright Page

  • Acknowledgments

  • About the Authors

  • Contents

  • Preface

  • 1 Introduction to Computers and C++

    • 1.1 Introduction

    • 1.2 Computers and the Internet in Industry and Research

    • 1.3 Hardware and Software

      • 1.3.1 Moore's Law

      • 1.3.2 Computer Organization

      • 1.4 Data Hierarchy

      • 1.5 Machine Languages, Assembly Languages and High-Level Languages

      • 1.6 C++

      • 1.7 Programming Languages

      • 1.8 Introduction to Object Technology

      • 1.9 Typical C++ Development Environment

      • 1.10 Test-Driving a C++ Application

      • 1.11 Operating Systems

        • 1.11.1 Windows—A Proprietary Operating System

        • 1.11.2 Linux—An Open-Source Operating System

Tài liệu cùng người dùng

Tài liệu liên quan