Transcription of The C++ Programming Language (Special 3rd Edition)
1 TheC+ +ProgrammingLanguageThird EditionBjarne StroustrupAT&T LabsMurray Hill, New JerseyAddison-WesleyAn Imprint of Addison Wesley Longman, , Massachusetts Harlow, England Menlo Park, CaliforniaBerkeley, California Don Mills, Ontario SydneyBonn Amsterdam Tokyo Mexico CityiiMany of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Wherethose designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have beenprinted in initial capital letters or all capital lettersThe author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of anykind and assume no responsibility for errors or omissions.
2 No liability is assumed for incidental or consequential damages inconnection with or arising out of the use of the information contained publisher offers discounts on this book when ordered in quantity for special sales. For more information please contact:Corporate & Professional Publishing GroupAddison-Wesley Publishing CompanyOne Jacob WayReading, Massachusetts 01867 Library of Congress Cataloging-in-Publication DataStroustrup, BjarneThe C++ Programming Language / Bjarne Stroustrup. 3rd. 0-201-88954-41.
3 C++(Computer Programming Language ) I. 1997 3 dc21 CIPC opyright 1997 by AT&TAll rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form orby any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of thepublisher. Printed in the United States of book was typeset in Times and Courier by the 0-201-88954-4 Printed on recycled paper1 2 3 4 5 6 7 8 9 CRW 0100999897 First printing, June 1997 ContentsContents iiiPreface vPreface to Second Edition viiPreface to First Edition ixIntroductory Material 11 Notes to the Reader.
4 32 A Tour of C++.. 213 A Tour of the Standard Library .. 45 Part I: Basic Facilities 674 Types and Declarations .. 695 Pointers, Arrays, and Structures .. 876 Expressions and Statements .. 1077 Functions .. 1438 Namespaces and Exceptions .. 1659 Source Files and Programs .. 197 The C++ Programming Language , Third Editionby Bjarne Stroustrup. Copyright 1997 by AT& by Addison Wesley Longman, Inc. ISBN 0-201-88954-4. All rights ContentsPart II: Abstraction Mechanisms 22110 Classes.
5 22311 Operator Overloading .. 26112 Derived Classes .. 30113 Templates .. 32714 Exception Handling .. 35515 Class Hierarchies .. 389 Part III: The Standard Library 42716 Library Organization and Containers .. 42917 Standard Containers .. 46118 Algorithms and Function Objects .. 50719 Iterators and Allocators .. 54920 Strings .. 57921 Streams .. 60522 Numerics .. 657 Part IV: Design Using C++68923 Development and Design.
6 69124 Design and Programming .. 72325 Roles of Classes .. 765 Appendices 791A The C++Grammar .. 793B Compatibility .. 815C Technicalities .. 827 Index 869 The C++ Programming Language , Third Editionby Bjarne Stroustrup. Copyright 1997 by AT& by Addison Wesley Longman, Inc. ISBN 0-201-88954-4. All rights is understanding. Kristen NygaardI find using C++more enjoyable than ever. C++ s support for design and Programming hasimproved dramatically over the years, and lots of new helpful techniques have been developed forits use.
7 However, C++is notjustfun. Ordinary practical programmers have achieved significantimprovements in productivity, maintainability, flexibility, and quality in projects of just about anykind and scale. By now, C++has fulfilled most of the hopes I originally had for it, and also suc-ceeded at tasks I hadn t even dreamt book introduces standard C++ and the key Programming and design techniques supportedby C++. Standard C++is a far more powerful and polished Language than the version of C++intro-duced by the first edition of this book.
8 New Language features such as namespaces, exceptions,templates, and run-time type identification allow many techniques to be applied more directly thanwas possible before, and the standard library allows the programmer to start from a much higherlevel than the bare a third of the information in the second edition of this book came from the first. Thisthird edition is the result of a rewrite of even larger magnitude. It offers something to even themost experienced C++programmer; at the same time, this book is easier for the novice to approachthan its predecessors were.
9 The explosion of C++use and the massive amount of experience accu-mulated as a result makes this definition of an extensive standard library makes a difference to the way C++concepts canbe presented. As before, this book presents C++independently of any particular implementation,and as before, the tutorial chapters present Language constructs and concepts in a bottom up order so that a construct is used only after it has been defined. However, it is much easier to use awell-designed library than it is to understand the details of its implementation.
10 Therefore, the stan-dard library can be used to provide realistic and interesting examples well before a reader can beassumed to understand its inner workings. The standard library itself is also a fertile source of pro-gramming examples and design ISO/IEC 14882, Standard for the C++ Programming C++ Programming Language , Third Editionby Bjarne Stroustrup. Copyright 1997 by AT& by Addison Wesley Longman, Inc. ISBN 0-201-88954-4. All rights PrefaceThis book presents every major C++ Language feature and the standard library.