The Design and Evolution of C++
C++ 的设计历史 C++ 的设计历史 C++ 的设计历史 C++ 的设计历史Library of Congress Cataloging-in-Publication DataStroustrup BjThe Design and Evolution of C++/ Bjarne StroustrupIncludes bibliographical references and indexISBN0-201-54330-31. C++(Computer program language) I Title.II. Title: Design and Evolution of C plus plusQA76.73.C153S791994005.13'3-dc2093-50758CIPat&TCopyright c 1994 by At&T Bell LabsAll rights reserved. No part of this publication may be reproduced, stored in a retrieval systemor transmitted, in any form or by any eans, electronic, Inechanical, photocopying, recording, orotherwise, without the prior written permission of the publisher. Printed in the United States ofAmericaThis book was typeset in Times Roman and Courier by the author12345678910MA-969594PrefaceHe who does not plowmust writeMartin a. hansenThe ACM HIOPL-2 conference on the llistory of Programming Languages asked meto write a paper on the history of C+t. This seemed a reasonable idea and a bit of anhonor, so I started writing. To get a more comprehensive and balanced view of C++'sgrowth, I asked a few friends from the early days of C++ for their recollections. Thatcaused news of this project to travel through the grapevine. There, the story mutated,and one day I received a message from a friend asking where he could buy my newbook on the design of c+t. that email message is the real origin of this bookTraditional books about programming and programming languages explain what alanguage is and how to use it. However, many people are also curious about why alanguage is the way it is and how it came to be that way This book answers these lasttwo questions for C++. It explains how C++ evolved from its first design to the language in use today. It describes the key problems, design aims, language ideas, andconstraints that shaped C+t, and how they changed over timeNaturally, C++ and the ideas about design and programming that shaped it didn'tjust mutate by themselves. What really evolved was the Ctt users'understanding oftheir practical problems and of the tools needed to help solve them. Consequentlythis book also traces the key problems tackled using C++ and the views of the peoplewho tackled them in ways that influenced C+tC++ is still a young language. Some of the issues discussed here are yet unknownto many users. Many implications of decisions described here will not become obvious for years to come. This book presents my view of how C++ came about, what ithow best to use C++ and in the continuing evolution of Ctx copiS, and what it ought to be. I hope this will be of help totrying to understandThe emphasis is on the overall design goals, practical constraints, and people thatshaped c-+. The key design decisions relating to language features are discussed andput into their historical context. The evolution of C++- is traced from C with Classesthrough Releasc 1.0 and 2.0 to the current ANSI/ISO standards work and the explosion of use, interest, commercial activity, compilers, tools, environments, andlibraries. C+'s relationship to C and Simula is discussed in detail. C++'s relationship to other languages is discussed briefly. The design of major language facilitiessuch as classes, inheritance, abstract classes, overloading, memory management, templates, exception handling, run-time type information, and namespaces are discussedin some detailThe primary aim of this book is to give C+ programmers a better idea of thebackground and fundamental concepts of their language and hopefully to inspire themto experiment with ways of using C=+ that are new to them. This book can also beread by experienced programmers and students of programming languages and mighthelp them decide whether using C++ might be worth their whileAcknowledgmentsI am very grateful to Steve Clamage, Tony Hansen, Lorraine Juhl, Peter Juhl, brianKernighan, Lee Knight, Doug Lea, Doug Mcllroy. Barbara Moo, Jens Palsberg, SteveRumsby, and Christopher Skelly for reading complete drafts of this book. Their con-structive comments caused major changes to the contents and organization of thisbook. Steve Buroff, Martin Carroll, Sean Corfield, Tom Hagelskjaer, Rick Hollin-beck, Dennis Mancl, and Stan Lippman helped by commenting on selected chaptersAlso, thanks to Archie Lachner for asking for this book before I had thought of writgNaturally i owe thanks to the many people who helped make Ci. In a sense, thisbook is a tribute to them and some of their names can be found throughout the chapters and in the index. Should I single out individuals, it must be brian KernighanAndrew Koenig, Doug Mcllroy, and Jonathan Shopiro. each of whom has been asteady source of help, encouragement, and ideas for more than a decade. Also, thanksto Kristen Nygaard and Dennis Ritchie as the designers of Simula and C from whichthe key ingredients of CH were borrowed. Over the years, I have come to appreciatethem not only as brilliant and practical language designers, but also as gentlemen andthoroughly likable individualsrray Hill, New JerseyBjarne stroustrupContentsPrefacellIAcknowledgmentsContentsNotes to the readertroductionHow to read this bookC+ Timeline4Focus on Use and usersProgramming languagesReferencesPart17The Prehistory of C++1.1 Simula and Distributed Sy1. 2 C and Systems Programming1.3 Gcneral BackgroundContentsC with Classes272.1 The Birth ofc with Classes272. 2 Feature overview2.3 Classes302.4 Run-Time Efficiency322. 5 The Linkage Model2.6 Static Type Checking402.7 Why C432.8 Syntax Problems452.9 Derived classes492.10 The protection model2.11 Run-Time guarantees2.12 Minor features2.13 Features Considered, but not provided592. 14 Work environment60The birth of c++633. 1 From C with Classes to C+633.2 Aims653.3 Cfre3.4 Language Features.713.5Ⅴ irtual functions3.6 Overloading783.7 Refe853.8 Constants893.9 Memory Management3.10 Type Checking3. 11 Minor features3.12 Relationship to classic C3.13 Tools for Language design3.14 The CH Programming Language(lst edition)1053.15 The Whatis? paper106C++ Language design rules1094. 1 Rules and Principles1094.2 General rules4.3 Design Support Rules4.4 Language- Technical rules1174.5 Low-Level Programming Support Rules1204.6 a Final wordChronology 1985-1993123I Introduction5.2 Release 2.05.3 The Annotated Reference Manual1265.4 ANSI and ISo Standardization.Standardization1336.1 what is a Standard?6.2 How does the Committee Operate?1366.3 Clarifications1386.4 Extensions1476.5 Examples of Proposed Extensions153Interest and Use1637.1 The Explosion in Interest and Use1637.2 Teaching and Learning c7.3 Users and Applications1737.4 Commercial Competition175Libraries1818.1 Introduction1818.2 C++ Lib8.3 Early Librariesraries198.5 A Standard Library194Looking Ahead1959.1 Introduction9.2 Retrospective9.3 Only a bridge9.4 What Will make C++ Much More Effective?205Ⅴ li ContentPart II209Memory management21110.1 Introduction.21110.2 Separating Allocation and Initialization21210.3 Array Allocation.21310.4 Plac21410.5 Deallocation problems21610.6 Memory Exhaustion.1810.7 Automatic garbage Collection219Overloading22311. 1 Introduction22311.2 Overload Resolution.2241.3 Type-Safe Linkage232I 1. 4 Object Creation and Co11.5 Notational Convenience11.6 Adding Operators to C++24711.7 Enumerations253Multiple inheritance2572.1 Introduction25712.2 Ordinary Base Classes12.3 Virtual Base Classes25912. 4 The Object Layout Model26412.5 Method combination26812. 6 The Multiple Inheritance Controversy26912. 7 Dele27212. 8 Renmin27312.9 Base and member InitializersClass Concept Refinements2773.1 Introduc27713.2 Abstract Classes13.3 cons t Member functions2843.4 Static member functions28813.5 Nested Classes28913.6 Inherited290Contents ix13.7 Relaxation of Overriding rules29313.8 Multi-methods13.9 Protected members30113.10 Improved Code Generation30213. 11 Pointers to members303Casting30514. 1 Major Extensions.30514.2 Run-Time Type Information30614.3 A New Cast NotationTemplates33715.1 Introduction3315.2 Templates33815.3 Class Templates34115.4 Constraints on Template Arguments15.5 Avoiding Code replication15.6 Function Templates34815.7 Syntax.158Co15.9 Template Class relahillps15.10 Template Instantiation15. 11 Implications of Templates378Exception llandlig38316.1 Introduction16.2 Aims and Assumptions38416. 3 Synta16.4 Grouping38616.5 Resource Management16.5 Resumption vs. Termina16.5As16.6 Multi-level pre39416.7 Static Checking39516. 8 Invariantslesp39917. 1 Introduction
下载地址
用户评论