1. Trang chủ
  2. » Khoa Học Tự Nhiên

Accelerated c++ practical programming by example 2000

336 122 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 336
Dung lượng 2,71 MB

Nội dung

Accelerated C++ Practical Programming by Example by Andrew Koenig and Barbara E Moo Addison-Wesley, 2000 ISBN 0-201-70353-X Pages 336 Second Printing Table of Contents Contents Chapter 0 Getting started 0.1 Comments 0.2 #include 0.3 The main function 0.4 Curly braces 0.5 Using the standard library for output 0.6 The return statement 0.7 A slightly deeper look 0.8 Details Chapter 1 Working with strings 1.1 Input 1.2 Framing a name 1.3 Details Chapter 2 Looping and counting 2.1 The problem 2.2 Overall structure 2.3 Writing an unknown number of rows 2.4 Writing a row 2.5 The complete framing program 2.6 Counting 2.7 Details Chapter 3 Working with batches of data 3.1 Computing student grades 3.2 Using medians instead of averages 3.3 Details Chapter 4 Organizing programs and data 4.1 Organizing computations 4.2 Organizing data 4.3 Putting it all together 4.4 Partitioning the grading program 4.5 The revised grading program 4.6 Details Chapter 5 Using sequential containers and analyzing strings 5.1 Separating students into categories 5.2 Iterators 5.3 Using iterators instead of indices 5.4 Rethinking our data structure for better performance 5.5 The list type 5.6 Taking strings apart 5.7 Testing our split function 5.8 Putting strings together 5.9 Details Chapter 6 Using library algorithms 6.1 Analyzing strings 6.2 Comparing grading schemes 6.3 Classifying students, revisited 6.4 Algorithms, containers, and iterators 6.5 Details Chapter 7 Using associative containers 7.1 Containers that support efficient look-up 7.2 Counting words 7.3 Generating a cross-reference table 7.4 Generating sentences 7.5 A note on performance 7.6 Details Chapter 8 Writing generic functions 8.1 What is a generic function? 8.2 Data-structure independence 8.3 Input and output iterators 8.4 Using iterators for flexibility 8.5 Details Chapter 9 Defining new types 9.1 Student_info revisited 9.2 Class types 9.3 Protection 9.4 The Student_info class 9.5 Constructors 9.6 Using the Student_info class 9.7 Details Chapter 10 Managing memory and low-level data structures 10.1 Pointers and arrays 10.2 String literals revisited 10.3 Initializing arrays of character pointers 10.4 Arguments to main 10.5 Reading and writing files 10.6 Three kinds of memory management 10.7 Details Chapter 11 Defining abstract data types 11.1 The Vec class 11.2 Implementing the Vec class 11.3 Copy control 11.4 Dynamic Vecs 11.5 Flexible memory management 11.6 Details Chapter 12 Making class objects act like values 12.1 A simple string class 12.2 Automatic conversions 12.3 Str operations 12.4 Some conversions are hazardous 12.5 Conversion operators 12.6 Conversions and memory management 12.7 Details Chapter 13 Using inheritance and dynamic binding 13.1 Inheritance 13.2 Polymorphism and virtual functions 13.3 Using inheritance to solve our problem 13.4 A simple handle class 13.5 Using the handle class 13.6 Subtleties 13.7 Details Chapter 14 Managing memory (almost) automatically 14.1 Handles that copy their objects 14.2 Reference-counted handles 14.3 Handles that let you decide when to share data 14.4 An improvement on controllable handles 14.5 Details Chapter 15 Revisiting character pictures 15.1 Design 15.2 Implementation 15.3 Details Chapter 16 Where do we go from here? 16.1 Use the abstractions you have 16.2 Learn more Appendix A Language details A.1 Declarations A.2 Types A.3 Expressions A.4 Statements Appendix B Library summary B.1 Input-output B.2 Containers and iterators B.3 Algorithms Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and we were aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein The publisher offers discounts on this book when ordered in quantity for special sales For more information, please contact: Pearson Education Corporate Sales Division One Lake Street Upper Saddle River, NJ 07458 (800) 382-3419 corpsales@pearsontechgroup.com Visit AW on the Web: www.awl.com/cseng/ Library of Congress Cataloging-in-Publication Data Koenig, Andrew Accelerated C++ : practical programming by example / Andrew Koenig, Barbara E Moo p cm Includes index ISBN 0-201-70353-X C++ (Computer program language) I Moo, Barbara E II Title QA76.73.C153 K67 2000 005.13'3dc21 00-040172 Copyright © 2000 by AT&T, Inc., and Barbara E Moo Cover photo copyright © 1995, 2000 by Andrew Koenig The authors typeset this book (pic | eqn | troff -mpm | dpost) in Palatino, Helvetica, and Courier, with assorted Sun Sparcstations, Hewlett-Packard laser printers, and two three helper cats All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher Printed in the United States of America Published simultaneously in Canada ISBN 0-201-70353-X Text printed on recycled paper 23456789 10MAO403020100 Second printing, November 2000 The C++ In-Depth Series Bjarne Stroustrup, Editor "I have made this letter longer than usual, because I lack the time to make it short " Blaise Pascal The advent of the ISO/ANSI C++ standard marked the beginning of a new era for C++ programmers The standard offers many new facilities and opportunities, but how can a real-world programmer find the time to discover the key nuggets of wisdom within this mass of information? The C++ In-Depth Series minimizes learning time and confusion by giving programmers concise, focused guides to specific topics Each book in this series presents a single topic, at a technical level appropriate to that topic The Series' practical approach is designed to lift professionals to their next level of programming skills Written by experts in the field, these short, in-depth monographs can be read and referenced without the distraction of unrelated material The books are cross-referenced within the Series, and also reference The C++ Programming Language by Bjarne Stroustrup As you develop your skills in C++, it becomes increasingly important to separate essential information from hype and glitz, and to find the in-depth content you need in order to grow The C++ In-Depth Series provides the tools, concepts, techniques, and new approaches to C++ that will give you a critical edge Titles in the Series Accelerated C++: Practical Programming by Example, Andrew Koenig and Barbara E Moo Essential C++, Stanley B Lippman Exceptional C++; 47 Engineering Puzzles, Programming Problems, and Solutions, Herb Sutter Modern C++ Design: Applied Generic Programming and Design Patterns, Andrei Alexandrescu For more information, check out the series Web site at http://www.aw.com/cseng/series/indepth/ Preface A new approach to C++ programming We assume that you want to learn quickly how to write useful C++ programs Therefore, we start by explaining the most useful parts of C++ This strategy may seem obvious when we put it that way, but it has the radical implication that we do not begin by teaching C, even though C++ builds on C Instead, we use high-level data structures from the start, explaining only later the foundations on which those data structures rest This approach lets you to begin writing idiomatic C++ programs immediately Our approach is unusual in another way: We concentrate on solving problems, rather than on exploring language and library features We explain the features, of course, but we do so in order to support the programs, rather than using the programs as an excuse to demonstrate the features Because this book teaches C++ programming, not just features/it is particularly useful for readers who already know some C++, and who want to use the language in a more natural, effective style Too often, people new to C++ learn the language mechanics without learning how to apply the language to everyday problems Our approach worksfor beginners and experienced programmers We used to teach a week-long intensive C++ course every summer at Stanford University We originally adopted a traditional approach to that course: Assuming that the students already knew C, we started by showing them how to define classes, and then moved systematically through the rest of the ... The C++ In-Depth Series provides the tools, concepts, techniques, and new approaches to C++ that will give you a critical edge Titles in the Series Accelerated C++: Practical Programming by Example, Andrew... Library of Congress Cataloging-in-Publication Data Koenig, Andrew Accelerated C++ : practical programming by example / Andrew Koenig, Barbara E Moo p cm Includes index ISBN 0-201-70353-X C++ (Computer program language) I Moo, Barbara E... Moo, Barbara E II Title QA76.73.C153 K67 2000 005.13'3dc21 00-040172 Copyright © 2000 by AT&T, Inc., and Barbara E Moo Cover photo copyright © 1995, 2000 by Andrew Koenig The authors typeset this book (pic | eqn | troff -mpm | dpost)

Ngày đăng: 25/03/2019, 17:13

TỪ KHÓA LIÊN QUAN