C++标准程序库.pdf

所需积分/C币:50 2013-02-26 09:16:08 4.55MB PDF
0
收藏 收藏
举报

内容简介 《C++标准程序库:自修教程与参考手册》包含最新资料的完整书籍,反映出被ANSI/ISO C++语言标准规格书纳入的C++标准程序库的最新组成。更明确地说,《C++标准程序库:自修教程与参考手册》将焦点放在标准模板库身上,检验其中的容器、迭代器、仿函数和算法。你还可以找到特殊容、字串、数值类别、国际化议题、IOStream。每一个元素都有深刻的呈现,包括其介绍、设计、运用实例、细部解说、陷阱、意想不到的危险,以及相关类别和函数的精确樯记式和定义式。 编辑本段 媒体评论 书评 C++标准程序库提供了一组通用类别(classes)和界面(interfaes),可大幅扩充C++核心语言
The C++ Standard Library C++ Standard library, The: A Tutorial and reference 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 Addison Wesley Longman Inc. was aware of a trademark claim the designations have been printed in initial caps or all caps. 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 AWL Direct sales Addison Wesley Longman, Inc One Jacob Way Reading Massachusetts o1867 (781)944-3700 VisitAwontheweB:www.awl.com/cseng/ Library of Congress Cataloging-in-Publication Data Josuttis. nicolai m The C++ standard library: a tutorial and reference /Nicolai M. Josuttis Includes bibliographical references and index 1. C++(Computer program language)I Title QA76.73C153J691999 005.133-dc219924977 CIP CopyrightC 1999 by Addison Wesley Longman, Inc 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 123456789CRW-0302010099 First printing, July 1999 dyne-book The C++ Standard Library Table of contents Preface Acknowledgments About this book 1.1 Why this book 1.2 What You Should Know Before reading this book 1.3 Style and structure of the book 1.4 How to read this book 1.5 State of the art 1.6 Example code and Additional Information 1.7 Feedback 2. Introduction to C++ and the standard library 2.1 History 2.2 New Language Features 2.3 Complexity and the big-O Notation 3. General Concepts 3. 1 Namespace std 3.2 Header files 3.3 Error and Exception Handling 3. 4 Allocators 4, Utilitⅰes 4.1 Pairs 4. 1. 1 Convenience Function make pair( 4.1.2 EXamples of Pair Usage 4.2 Class auto ptr 4.3 Numeric Limits 4. 4 Auxiliary Functions 4.5 Supplementary Comparison Operators 4.6 Header files <cstddef> and <cstdlib> 5.The Standard Template Library 5.1 STL Components 5.2 Containers 5.3 iterators 5.4 Algorithm 5.5 Iterator Adapters 5.6 Manipulating algorithms 5.7 User-Defined generic functions 5.8 Functions as Algorithm Arguments 5.9 Function Objects 5.10 Container elements 5.11 Errors and Exceptions Inside the STL 5.12 Extending the stL 6. STL Containers 6.1 Common Container abilities and Operations 6.2 Vectors 3 Deque yne-bO The C++ Standard Library 6. 4 Lists 6.5 Sets and multisets 6.6 Maps and multimaps 6.7 Other sTL Containers 6.8 Implementing Reference Semantics 6.9 When to Use which Container 6.10 Container Types and members in deta 7. STL Iterators 7. 1 Header Files for Iterators 7.2 Iterator Categories 7.3 Auxiliary Iterator Functions 7. 4 Iterator Adapters 7.5 Iterator traits 8. STL Function Obiects 8. 1 The Concept of Function objects 8.2 Predefined Function Obiects 8.3 Supplementary Composing Function Obiects 9. STL Algorithms 9.1 Algorithm Header Files 9.2 Algorithm Overview 9.3 Auxiliary Functions 9.4 The for each( Algorith 9.5 Nonmodifying algorithms 9.6 Modifying algorithms 9.7 Removing Algorithms 9.8 Mutating Algorithms 9.9 Sorting Algorithms 9.10 Sorted Range algorithms 9.11 Numeric Algorithms 10.Special Containers 10.1 Stacks 10.2 Queues 10.3 Priority Queues 10. 4 Bitsets 11. Strings 11. 1 Motivation 11.2 Description of the string classes 11.3 String Class in Detail 12. Numerics 12.1 Complex Numbers 12.2 Valarray 12.3 Global numeric functions 13.Input/Output Using Stream Classes 13. Input/Output Using stream Classes 13.1 Common Background of I/o Streams 13.2 Fundamental stream Classes and obiects dyne-book The C++ Standard Library 13.3 Standard Stream Operators < and>> 13.4 State of streams 13.5 Standard input/output Functions 3.6 Manipulators 13.7 Formatting 13. 8 Internationalization 13.9 File access 13.10 Connecting Input and Output Streams 13.11 Stream Classes for Strings 13.12 Input/output Operators for User-Defined Types 3.13 The stream buffer Classes 13,14 Performance issues 14. Internationalization 14.1 Different Character Encodings 14.2 The Concept of Locales 14.3 Locales in detail 14. 4 Facets in detail 15. Allocators 15.1 Using Allocators as an Application Programmer 15.2 Using Allocators as a Library programmer 15.3 The default allocator 15.4A User-Defined allocator 15.5 Allocators in detail 15.6 Utilities for Uninitialized memory in detail Internet resources Where You can get the standard Internet Addresses/URls Bibliography dyne-book The C++ Standard Library Preface In the beginning, I only planned to write a small German book(400 pages or so)about the C++ standard library. That was in 1993. Now, in 1999 you see the result- an English book with more than 800 pages of facts, figures, and examples. My goal is to describe the C++ standard library so that all (or almost all) your programming questions are answered before you think of the question Note, however, that this is not a complete description of all aspects of the C++ standard library. Instead, I present the most important topics necessary for learning and programming in C++ by using its standard library Each topic is described based on the general concepts, this discussion then leads to the specific details needed to support every-day programming tasks. Specific code examples are provided to help you understand the concepts and the details That's it-in a nutshell. I hope you get as much pleasure from reading this book as I did from writing it. Enjoy dyne-book The C++ Standard Library Acknowledgments This book presents ideas, concepts, solutions, and examples from many sources. In a way it does not seem fair that my name is the only name on the cover. Thus, I'd like to thank all the people and companies who helped and supported me during the past few years First, I'd like to thank dietmar Kuhl. Dietmar is an expert on C++, especially on input/output streams and internationalization(he implemented an l/o stream library just for fun ) He not onl translated major parts of this book from German to English, he also wrote sections of this book using his expertise. In addition, he provided me with invaluable feedback over the years Second, I'd like to thank all the reviewers and everyone else who gave me their opinion. These people endow the book with a quality it would never have had without their input (Because the list is extensive, please fogive me for any oversight. The reviewers for the English version of this book included Chuck Allison, Greg Comeau, James A. Crotinger, Gabriel Dos Reis, Alan Ezust Nathan Meyers, Werner Mossner, Todd Veldhuizen, Chichiang Wan, Judy Ward, and Thomas Wikehult. the german reviewers included Ralf boecker, Dirk herrmann Dietmar Kuhl. Edda Lorke, Herbert Scheubner, Dominik Strasser, and Martin Weitzel. Additional input was provided by Matt Austern, Valentin Bonnard, Greg Colvin, Beman Dawes, Bill Gibbons, Lois Goldthwaite Andrew Koenig, Steve Rumbsby, Bjarne Stroustrup, and David Vandevoorde Special thanks to Dave Abrahams, Janet Cocker, Catherine Ohala, and Maureen Willard who reviewed and edited the whole book very carefully. Their feedback was an incredible contribution to the quality of this book A special thanks goes to my " personal living dictionary"-Herb Sutter- the author of the famous"Guru of the Week"(a regular series of C++ programming problems that is published on the comp. std. C++, moderated Internet newsgroup) Id also like to thank all the people and companies who gave me the opportunity to test my examples on different platforms with different compilers. Many thanks to Steve Adamczyk, Mike Anderson, and John Spicer from EDG for their great compiler and their support. It was a big help during the standardization process and the writing of this book. Many thanks to P.J. Plauger and Dinkumware, Ltd, for their early standard-conforming implementation of the C++ standard library Many thanks to Andreas Hommel and Metrowerks for an evaluative version of their Code Warrior Programming Environment. Many thanks to all the developers of the free GNU and egcs compilers. Many thanks to microsoft for an evaluative version of visual c+t. many thanks to Roland Hartinger from Siemens Nixdorf Informations Systems AG for a test version of their C++ compiler. Many thanks to Topjects GmbH for an evaluative version of the ObjectSpace library implementation Catherine Ohala, Marty Rabinowitz, Susanne Spitzer, and Maureen Willard It wasfugo Many thanks to everyone from Addison Wesley Longman who worked with me. Among others this includes Janet Cocker, Mike Hendrickson, Debbie Lafferty, Marina Lang, Chanda Leary, In addition, Id like to thank the people at bredEX Gmbh and all the people in the C++ community, particularly those involved with the standardization process, for their support and patience(sometimes I ask really silly questions Last but not least, many thanks and kisses for my family: Ulli, Lucas, Anica, and Frederic definitely did not have enough time for them due to the writing of this book Have fun and be human! dyne-book The C++ Standard Library Chapter 1. About this Book 1.1 Why this book Soon after its introduction, C++ became a de facto standard in object-oriented programming This led to the goal of standardization. Only by having a standard, could programs be written that would run on different platforms - from PCs to mainframes. Furthermore, a standard library would enable programmers to use general components and a higher level of abstraction without losing portability, rather than having to develop all code from scratch The standardization process was started in 1989 by an international ANSI/Iso committee developed the standard based on Bjarne Stroustrup,'s books The C++ Programming Language and The Annotated C++ Reference Manual. After the standard was completed in 1997, several formal motions by different countries made it an international iso and ansi standard in 1998 The standardization process included the development of a C++ standard library. The library extends the core language to provide some general components. By using C++'s ability to program new abstract and generic types, the library provides a set of common classes and interfaces. This gives programmers a higher level of abstraction. The library provides the ability to use String types Different data structures(such as dynamic arrays, linked lists, and binary trees Different algorithms(such as different sorting algorithms) Numeric classes Input/output (1/o)classes Classes for internationalization support All of these are supported by a fairly simple programming interface. These components are very important for many programs. These days, data processing often means inputting, computing, processing: and outputting large amounts of data, which are often strings The library is not self-explanatory. To use these components and to benefit from their power, you need a good introduction that explains the concepts and the important details instead of simply isting the classes and their functions. This book is written exactly for that purpose. First, it introduces the library and all of its components from a conceptional point of view. Next describes the details needed for practical programming. Examples are included to demonstrate the exact usage of the components. Thus, this book is a detailed introduction to the C++ library for both the beginner and the practical programmer. Armed with the data provided herein, you should be able to take full advantage of the C++ standard library Caveat: dont promise that everything described is easy and self-explanatory. The library provides a lot of flexibility, but flexibility for nontrivial purposes has a price. Beware that the library has traps and pitfalls, which I point out when we encounter them and suggest ways of avoiding them 1.2 What You Should Know Before Reading this Book To get the most from this book you should already know C++. (The book describes the standard components of C++, but not the language itself. )You should be familiar with the concepts of classes, inheritance, templates, and exception handling. However, you dont have to know all of the minor details about the language. The important details are described in the book( the minor dyne-book The C++ Standard Library details about the language are more important for people who want to implement the library rather than use it). Note that the language has changed during the standardization process, so your knowledge might not be up to date. section 2.2, provides a brief overview and introduction of the latest language features that are important for using the library. You should read this section if you are not sure whether you know all the new features of C++(such as the keyword typename and the concept of namespaces) 1.3 Style and Structure of the Book The C++ standard library provides different components that are somewhat but not totally independent of each other, so there is no easy way to describe each part without mentioning others. I considered several different approaches for presenting the contents of this book. One was on the order of the C++ standard. However, this is not the best way to explain the components of the C++ standard library from scratch another was to start with an overview of all components followed by chapters that provided more details. Alternatively, I could have sorted the components, trying to find an order that had a minimum of cross- references to other sections My solution was to use a mixture of all three approaches. I start with a brief introduction of the general concepts and the utilities that are used by the library. Then, I describe all the components, each in one or more chapters. The first component is the standard template library (STL). There is no doubt that the STL is the most powerful, most complex, and most exciting part of the library. Its design influences other components heavily. Then I describe the more self- explanatory components, such as special containers, strings, and numeric classes. The next component discussed is one you probably know and use already: the IOStream library. It is followed by a discussion of internationalization, which had some influence on the ioStream library Each component description begins with the component's purpose, design, and some examples Next, a detailed description follows that begins with different ways to use the component, as well as any traps and pitfalls associated with it. The description usually ends with a reference section, in which you can find the exact signature and definition of a component's classes and its functions The following is a description of the books contents. The first four chapters introduce this book and the C++ standard library in general Chapter 1: About this Book This chapter(which you are reading right now)introduces the book's subject and describes its contents Chapter 2: Introduction to C++ and the Standard library This chapter provides a brief overview of the history of the C++ standard library and the context of its standardization It also contains some general hints regarding the technical background for this book and the library such as new language features and the concept OT complexity Chapter 3: General Concepts This chapter describes the fundamental concepts of the library that you need to understand to work with all the components. In particular, it introduces the namespace std, the format of header files, and the general support of error and exception handling Chapter 4: Utilities dyne-book

...展开详情
试读 127P C++标准程序库.pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
吕龙宝 虽说是英文版的,但是和中文版的对比着看有好处
2015-07-21
回复
Hershaw 英文版的,很清晰,谢谢分享
2015-01-18
回复
huxijiuhao 还没看,不过是很好的资源
2015-01-05
回复
杭州大擎科技有限公司 书就是好,挺好的
2014-12-16
回复
791068857 挺好的资源 要是免费就好了
2014-11-10
回复
dy00544 英文版第一版的,看着清晰,谢谢分享
2014-10-13
回复
stey_navy 刚开始学习C++,正在寻找相关资料,很有帮助,谢谢了!
2014-08-21
回复
绿野耕夫 英文版的,看着清晰,谢谢分享
2014-07-26
回复
csq镜子的月亮 全英,,喜欢的,可以顺便练练英语了,谢谢楼主
2014-07-19
回复
上帝快跑 英文的,很清晰,可惜英语不好
2014-07-15
回复
  • 领英

    绑定领英第三方账户获取
  • GitHub

    绑定GitHub第三方账户获取
  • 脉脉勋章

    绑定脉脉第三方账户获得
  • 签到新秀

    累计签到获取,不积跬步,无以至千里,继续坚持!
  • 分享王者

    成功上传51个资源即可获取
关注 私信 TA的资源
上传资源赚积分or赚钱
    最新推荐
    C++标准程序库.pdf 50积分/C币 立即下载
    1/127
    C++标准程序库.pdf第1页
    C++标准程序库.pdf第2页
    C++标准程序库.pdf第3页
    C++标准程序库.pdf第4页
    C++标准程序库.pdf第5页
    C++标准程序库.pdf第6页
    C++标准程序库.pdf第7页
    C++标准程序库.pdf第8页
    C++标准程序库.pdf第9页
    C++标准程序库.pdf第10页
    C++标准程序库.pdf第11页
    C++标准程序库.pdf第12页
    C++标准程序库.pdf第13页
    C++标准程序库.pdf第14页
    C++标准程序库.pdf第15页
    C++标准程序库.pdf第16页
    C++标准程序库.pdf第17页
    C++标准程序库.pdf第18页
    C++标准程序库.pdf第19页
    C++标准程序库.pdf第20页

    试读结束, 可继续阅读

    50积分/C币 立即下载 >