📄 e.htm
字号:
<!-- SectionName="EC++ Acknowledgements" -->
<A NAME="52"></A><A NAME="pxvii"></A><DIV ALIGN="CENTER"><FONT SIZE="-1">Back to <A HREF="#32">Preface</A>
<BR>Continue to <A HREF="#1709">Introduction</A></FONT></DIV>
<P><A NAME="dingp20"></A><FONT ID="egtitle">Acknowledgments</FONT><SCRIPT>create_link(20);</SCRIPT>
</P>
<P><A NAME="dingp21"></A>
Some three decades have elapsed since Kathy Reed taught me what a computer was and how to program one, so I suppose this is really all her fault. In 1989, Donald French asked me to develop C++ training materials for the Institute for Advanced Professional Studies, so perhaps he should shoulder some blame. The students in my class at Stratus Computer the week of June 3, 1991, were not the first to suggest I write a book summarizing the pearls of alleged wisdom that tumble forth when I teach, but they were the ones who finally convinced me to do it, so they bear some of the responsibility. I'm grateful to them <NOBR>all.<SCRIPT>create_link(21);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp22"></A><A NAME="552"></A>
Many of the Items and examples in this book have no particular source, at least not one I can remember. Instead, they grew out of a combination of my own experiences using and teaching C++, those of my colleagues, and opinions expressed by contributors to the Usenet C++ newsgroups. Many examples that are now standard in the C++ teaching community — notably strings — can be traced back to the initial edition of Bjarne Stroustrup's <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cpl" onMouseOver="self.status='The C++ Programming Language Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>The</NOBR> C++ Programming Language</I></A> (Addison-Wesley, 1986). Several of the Items found here (e.g., <A HREF="#2264"onMouseOver = "self.status = 'Item 17'; return true" onMouseOut = "self.status = self.defaultStatus">Item 17</A>) can also be found in that seminal <NOBR>work.<SCRIPT>create_link(22);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp23"></A><A NAME="7818"></A>
<A HREF="#128051"onMouseOver = "self.status = 'Item 8'; return true" onMouseOut = "self.status = self.defaultStatus">Item 8</A> includes an implementation idea from Steve Clamage's May 1993 <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cppreport" onMouseOver="self.status='C++ Report Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>C++</NOBR> Report</I></A> article, "Implementing <CODE>new</CODE> and <CODE>delete</CODE>." <A HREF="#1961"onMouseOver = "self.status = 'Item 9'; return true" onMouseOut = "self.status = self.defaultStatus">Item 9</A> was motivated by commentary in <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=anncrm" onMouseOver="self.status='The Annotated C++ Reference Manual Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>The</NOBR> Annotated C++ Reference Manual</I></A> (see <A HREF="#8569"onMouseOver = "self.status = 'Item 50'; return true" onMouseOut = "self.status = self.defaultStatus">Item 50</A>), and Items <A HREF="#1986"onMouseOver = "self.status = '10'; return true" onMouseOut = "self.status = self.defaultStatus">10</A> and <A HREF="#2117"onMouseOver = "self.status = '13'; return true" onMouseOut = "self.status = self.defaultStatus">13</A> were suggested by John Shewchuk. The implementation of <CODE>operator</CODE> <CODE>new</CODE> in <A HREF="#1986"onMouseOver = "self.status = 'Item 10'; return true" onMouseOut = "self.status = self.defaultStatus">Item 10</A> is based on presentations in the second edition of Stroustrup's <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cpl" onMouseOver="self.status='The C++ Programming Language Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>The</NOBR> C++ Programming Language</I></A> (Addison-Wesley, 1991) and Jim Coplien's <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=apsi" onMouseOver="self.status='Advanced C++: Programming Styles and Idioms Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>Advanced</NOBR> C++: Programming Styles and Idioms</I></A> (Addison-Wesley, 1992). Dietmar Kühl pointed out the undefined behavior I describe in <A HREF="#223029"onMouseOver = "self.status = 'Item 14'; return true" onMouseOut = "self.status = self.defaultStatus">Item 14</A>. Doug Lea provided the aliasing examples at the end of <A HREF="#2264"onMouseOver = "self.status = 'Item 17'; return true" onMouseOut = "self.status = self.defaultStatus">Item 17</A>. The idea of using <CODE>0L</CODE> for <CODE>NULL</CODE> in <A HREF="#6292"onMouseOver = "self.status = 'Item 25'; return true" onMouseOut = "self.status = self.defaultStatus">Item 25</A> came from Jack Reeves's March 1996 <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cppreport" onMouseOver="self.status='C++ Report Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>C++</NOBR> Report</I></A> article, <A NAME="pxviii"></A><A HREF="../MAGAZINE/RE_FRAME.HTM" TARGET="_top" onMouseOver = "self.status = 'Coping with Exceptions'; return true" onMouseOut = "self.status = self.defaultStatus">"Coping with Exceptions."</A> Several members of various Usenet C++ newsgroups helped refine that Item's class for implementing <CODE>NULL</CODE>-based pointer conversions via member templates. A newsgroup posting by Steve Clamage tempered my enthusiasm for references to functions in <A HREF="#6429"onMouseOver = "self.status = 'Item 28'; return true" onMouseOut = "self.status = self.defaultStatus">Item 28</A>. <A HREF="#6729"onMouseOver = "self.status = 'Item 33'; return true" onMouseOut = "self.status = self.defaultStatus">Item 33</A> incorporates observations from Tom Cargill's <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cps" onMouseOver="self.status='C++ Programming Style Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>C++</NOBR> Programming Style</I></A> (Addison-Wesley, 1992), Martin Carroll's and Margaret Ellis's <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=dcr" onMouseOver="self.status='Designing and Coding Resuable C++ Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>Designing</NOBR> and Coding Reusable C++</I></A> (Addison-Wesley, 1995), <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=talgdp" onMouseOver="self.status='Taligent`s Guide to Designing Programs Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>Taligent's</NOBR> Guide to Designing Programs</I></A> (Addison-Wesley, 1994), Rob Murray's <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cstrtac" onMouseOver="self.status='C++ Strategies and Tactics Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>C++</NOBR> Strategies and Tactics</I></A> (Addison-Wesley, 1993), as well as information from publications and newsgroup postings by Steve Clamage. The material in <A HREF="#6793"onMouseOver = "self.status = 'Item 34'; return true" onMouseOut = "self.status = self.defaultStatus">Item 34</A> benefited from my discussions with John Lakos and from reading his book, <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=lscs" onMouseOver="self.status='Large-Scale C++ Software Design Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>Large-Scale</NOBR> C++ Software Design</I></A> (Addison-Wesley, 1996). The envelope/letter terminology in that Item comes from Jim Coplien's <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=apsi" onMouseOver="self.status='Advanced C++: Programming Styles and Idioms Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>Advanced</NOBR> C++: Programming Styles and Idioms</I></A>; John Carolan coined the delightful term, "Cheshire Cat class." The rectangle/square example of <A HREF="#6914"onMouseOver = "self.status = 'Item 35'; return true" onMouseOut = "self.status = self.defaultStatus">Item 35</A> is taken from Robert Martin's March 1996 <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cppreport" onMouseOver="self.status='C++ Report Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>C++</NOBR> Report</I></A> column, "The Liskov Substitution Principle." A long-ago <CODE>comp.lang.c++</CODE> posting by Mark Linton set me straight in my thinking about grasshoppers and crickets in <A HREF="#7778"onMouseOver = "self.status = 'Item 43'; return true" onMouseOut = "self.status = self.defaultStatus">Item 43</A>. My traits examples in <A HREF="#8392"onMouseOver = "self.status = 'Item 49'; return true" onMouseOut = "self.status = self.defaultStatus">Item 49</A> are taken from Nathan Myers's June 1995 <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cppreport" onMouseOver="self.status='C++ Report Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>C++</NOBR> Report</I></A> article, <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=ttt" onMouseOver="self.status='A New and Useful Template Technique: Traits'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top">"A</NOBR> New and Useful Template Technique: Traits,"</A> and Pete Becker's "C/C++ Q&A" column in the November 1996 <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=cuj" onMouseOver="self.status='C++/C++ Users Journal Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>C/C++</NOBR> User's Journal</I></A>; my summary of C++'s internationalization support is based on a pre-publication book draft by Angelika Langer and Klaus Kreft. Of course, "Hello world" comes from <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=c2pl" onMouseOver="self.status='The C Programming Language Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>The</NOBR> C Programming Language</I></A> by Brian Kernighan and Dennis Ritchie (Prentice-Hall, first publish in <NOBR>1978).<SCRIPT>create_link(23);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp24"></A><A NAME="428"></A>
Many readers of the first edition sent suggestions I was unable to incorporate in that version of the book, but that I've adopted in one form or another for this new edition. Others took advantage of Usenet C++ newsgroups to post insightful remarks about the material in the book. I'm grateful to each of the following individuals, and I've noted where I took advantage of their ideas: Mike Kaelbling and Julio Kuplinsky (Introduction); a person my notes identify only as "a guy at Claris"<A HREF="#474"onMouseOver = "self.status = 'See Footnote 2'; return true" onMouseOut = "self.status = self.defaultStatus"><sup>2</sup></A> (<A HREF="#1869"onMouseOver = "self.status = 'Item 5'; return true" onMouseOut = "self.status = self.defaultStatus">Item 5</A>); Joel Regen and Chris Treichel (<A HREF="#1894"onMouseOver = "self.status = 'Item 7'; return true" onMouseOut = "self.status = self.defaultStatus">Item 7</A>); Tom Cargill, Larry Gajdos, Doug Morgan, and Uwe Steinmüller (<A HREF="#1986"onMouseOver = "self.status = 'Item 10'; return true" onMouseOut = "self.status = self.defaultStatus">Item 10</A>); Roger Scott and Steve Burkett (<A HREF="#2071"onMouseOver = "self.status = 'Item 12'; return true" onMouseOut = "self.status = self.defaultStatus">Item 12</A>); David Papurt (<A HREF="#2117"onMouseOver = "self.status = 'Item 13'; return true" onMouseOut = "self.status = self.defaultStatus">Item 13</A>); Alexander Gootman (<A HREF="#223029"onMouseOver = "self.status = 'Item 14'; return true" onMouseOut = "self.status = self.defaultStatus">Item 14</A>); David Bern (<A HREF="#2225"onMouseOver = "self.status = 'Item 16'; return true" onMouseOut = "self.status = self.defaultStatus">Item 16</A>); Tom Cargill, Tom Chappell, Dan Fran<A NAME="pxix"></A>klin, and Jerry Liebelson (<A HREF="#2264"onMouseOver = "self.status = 'Item 17'; return true" onMouseOut = "self.status = self.defaultStatus">Item 17</A>); John "Eljay" Love-Jensen (<A HREF="#5887"onMouseOver = "self.status = 'Item 19'; return true" onMouseOut = "self.status = self.defaultStatus">Item 19</A>); Eric Nagler (<A HREF="#6133"onMouseOver = "self.status = 'Item 22'; return true" onMouseOut = "self.status = self.defaultStatus">Item 22</A>); Roger Eastman, Doug Moore, and Aaron Naiman (<A HREF="#6210"onMouseOver = "self.status = 'Item 23'; return true" onMouseOut = "self.status = self.defaultStatus">Item 23</A>); Dat Thuc Nguyen (<A HREF="#6292"onMouseOver = "self.status = 'Item 25'; return true" onMouseOut = "self.status = self.defaultStatus">Item 25</A>); Tony Hansen, Natraj Kini, and Roger Scott (<A HREF="#6729"onMouseOver = "self.status = 'Item 33'; return true" onMouseOut = "self.status = self.defaultStatus">Item 33</A>); John Harrington, Read Fleming, and Dave Smallberg (<A HREF="#6793"onMouseOver = "self.status = 'Item 34'; return true" onMouseOut = "self.status = self.defaultStatus">Item 34</A>); Johan Bengtsson (<A HREF="#7007"onMouseOver = "self.status = 'Item 36'; return true" onMouseOut = "self.status = self.defaultStatus">Item 36</A>); Rene Rodoni (<A HREF="#7269"onMouseOver = "self.status = 'Item 39'; return true" onMouseOut = "self.status = self.defaultStatus">Item 39</A>); Paul Blankenbaker and Mark Somer (<A HREF="#7424"onMouseOver = "self.status = 'Item 40'; return true" onMouseOut = "self.status = self.defaultStatus">Item 40</A>); Tom Cargill and John Lakos (<A HREF="#7611"onMouseOver = "self.status = 'Item 41'; return true" onMouseOut = "self.status = self.defaultStatus">Item 41</A>); Frieder Knauss and Roger Scott (<A HREF="#21052"onMouseOver = "self.status = 'Item 42'; return true" onMouseOut = "self.status = self.defaultStatus">Item 42</A>);
David Braunegg, Steve Clamage, and Dawn Koffman (<A HREF="#8160"onMouseOver = "self.status = 'Item 45'; return true" onMouseOut = "self.status = self.defaultStatus">Item 45</A>); Tom Cargill (<A HREF="#195225"onMouseOver = "self.status = 'Item 46'; return true" onMouseOut = "self.status = self.defaultStatus">Item 46</A>); Wesley Munsil (<A HREF="#8299"onMouseOver = "self.status = 'Item 47'; return true" onMouseOut = "self.status = self.defaultStatus">Item 47</A>); Randy Mangoba (most class definitions); and John "Eljay" Love-Jensen (many places where I use <CODE>type double</CODE>).<SCRIPT>create_link(24);</SCRIPT>
</P>
<P><A NAME="dingp25"></A><A NAME="57"></A>
Partial and/or complete drafts of the manuscript for the first edition were reviewed by Tom Cargill, Glenn Carroll, Tony Davis, Brian Kernighan, Jak Kirman, Doug Lea, Moises Lejter, Eugene Santos, Jr., John Shewchuk, John Stasko, Bjarne Stroustrup, Barbara Tilly, and Nancy L. Urbano. In addition, I received suggestions for improvements that I was able to incorporate in later printings from the following alert readers, whom I've listed in the order in which I received their reports: Nancy L. Urbano, Chris Treichel, David Corbin, Paul Gibson, Steve Vinoski, Tom Cargill, Neil Rhodes, David Bern, Russ Williams, Robert Brazile, Doug Morgan, Uwe Steinmüller, Mark Somer, Doug Moore, Dave Smallberg, Seth Meltzer, Oleg Shteynbuk, David Papurt, Tony Hansen, Peter McCluskey, Stefan Kuhlins, David Braunegg, Paul Chisholm, Adam Zell, Clovis Tondo, Mike Kaelbling, Natraj Kini, Lars Nyman, Greg Lutz, Tim Johnson, John Lakos, Roger Scott, Scott Frohman, Alan Rooks, Robert Poor, Eric Nagler, Antoine Trux, Cade Roux, Chandrika Gokul, Randy Mangoba, and Glenn Teitelbaum. Each of these people was instrumental in improving the book you now <NOBR>hold.<SCRIPT>create_link(25);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp26"></A><A NAME="7604"></A>
Drafts of the second edition were reviewed by Derek Bosch, Tim Johnson, Brian Kernighan, Junichi Kimura, Scott Lewandowski, Laura Michaels, Dave Smallberg, Clovis Tondo, Chris Van Wyk, and Oleg Zabluda. I am grateful to all these people, but especially to Tim Johnson, whose detailed review influenced the final manuscript in dozens of ways. I am also grateful to Jill Huchital and Steve Reiss for their assistance in finding good reviewers, a task of crucial importance and increasing difficulty. Dawn Koffman and Dave Smallberg suggested improvements to the <FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=training" onMouseOver="self.status='C++ training materials'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top">C++ training materials</A> derived from my books, and many of their ideas have found their way into this revision. Finally, I received comments from the following readers of earlier printings of this book, and I've modified this current printing to take their suggestions into account: Daniel Steinberg, Arunprasad Marathe, Doug Stapp, Robert Hall, Cheryl Ferguson, Gary Bartlett, Michael Tamm, Kendall Beaman, <A NAME="pxx"></A>Eric Nagler, Max Hailperin, Joe Gottman, Richard Weeks, Valentin Bonnard, Jun He, Tim King, Don Maier, Ted Hill, Mark Harrison, Michael Rubenstein, Mark Rodgers, David Goh, Brenton Cooper, and Andy <NOBR>Thomas-Cramer.<SCRIPT>create_link(26);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp27"></A><A NAME="7592"></A>
Evi Nemeth (with the cooperation of <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com" TARGET="_top" onMouseOver = "self.status = 'Addison-Wesley'; return true" onMouseOut = "self.status = self.defaultStatus">Addison-Wesley</NOBR></A>, the <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=usenix" onMouseOver="self.status='USENIX Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top">USENIX Association</A>, and <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=ietf" onMouseOver="self.status='Internet Engineering Task Force Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top">The</NOBR> Internet Engineering Task Force</A>) has agreed to see to it that leftover copies of the first edition are delivered to computer science laboratories at universities in Eastern Europe; these universities would otherwise find it difficult to acquire such books. Evi voluntarily performs this service for several authors and publishers, and I'm happy to be able to help in some small way. If you'd like more information on this program, <A HREF="mailto:evi@cs.colorado.edu"onMouseOver = "self.status = 'Send mail to Evi'; return true" onMouseOut = "self.status = self.defaultStatus">contact Evi</A>.<SCRIPT>create_link(27);</SCRIPT>
</P>
<P><A NAME="dingp28"></A><A NAME="1056"></A>
Sometimes it seems that the players in publishing change nearly as frequently as the trends in programming, so I'm pleased that my editor, John Wait, my marketing director, Kim Dawley, and my production director, Marty Rabinowitz, continue to play the roles they did in those innocent days of 1991 when I first started this whole authoring thing. Sarah Weaver was my project manager for this book, Rosemary Simpson provided advice on indexing, and Lana Langlois acted as my primary contact and all-around übercoordinator at Addison-Wesley until she left for greener — or at least different — pastures. I thank them and their colleagues for helping with the thousand tasks that separate simple writing from actual <NOBR>publishing.<SCRIPT>create_link(28);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp29"></A><A NAME="1050"></A>
Kathy Wright had nothing to do with the book, but she'd like to be <NOBR>acknowledged.<SCRIPT>create_link(29);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp30"></A><A NAME="307"></A>
For the first edition, I am grateful for the enthusiastic and unflagging encouragement provided by my wife, Nancy L. Urbano, and by my family and hers. Although writing a book was the last thing I was supposed to be doing, and doing so reduced my free time from merely little to effectively none, they made it clear that the effort was worth it if, in the end, the result was an author in the <NOBR>family.<SCRIPT>create_link(30);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp31"></A><A NAME="1347"></A>
That author has been in the family six years now, yet Nancy continues to tolerate my hours, put up with my technochatter, and encourage my writing. She also has a knack for knowing just the right word when I can't think of it. The Nancyless life is not worth <NOBR>living.<SCRIPT>create_link(31);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp32"></A><A NAME="1388"></A>
Our dog, <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>°</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=pers" onMouseOver="self.status='Persephone\'s Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top">Persephone</NOBR></A>, never lets me confuse my priorities. Deadline or no deadline, the time for a walk is always <I>now</I>.<SCRIPT>create_link(32);</SCRIPT>
</P>
<!-- SectionName="EC++ Introduction" -->
<A NAME="1709"></A><A NAME="p1"></A><DIV ALIGN="CENTER"><FONT SIZE="-1">Back to <A HREF="#52">Acknowledgments</A>
<BR>Continue to <A HREF="#222823">Shifting from C to C++</A></FONT></DIV>
<P><A NAME="dingp33"></A><FONT ID="egtitle">Introduction</FONT><SCRIPT>create_link(33);</SCRIPT>
</P>
<P><A NAME="dingp34"></A>
Learning the fundamentals of a programming language is one thing; learning how to design and implement <I>effective</I> programs in that language is something else entirely. This is especially true of C++, a language boasting an uncommon range of power and expressiveness. Built atop a full-featured conventional language (C), it also offers a wide range of object-oriented features, as well as support for templates and <NOBR>exceptions.<SCRIPT>create_link(34);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp35"></A><A NAME="1710"></A>
Properly used, C++ can be a joy to work with. An enormous variety of designs, both object-oriented and conventional, can be expressed directly and implemented efficiently. You can define new data types that are all but indistinguishable from their built-in counterparts, yet are substantially more flexible. A judiciously chosen and carefully crafted set of classes — one that automatically handles memory management, aliasing, initialization and clean-up, type conversions, and all the other conundrums that are the bane of software developers — can make application programming easy, intuitive, efficient, and nearly error-free. It isn't unduly difficult to write effective C++ programs, <I>if</I> you know how to do <NOBR>it.<SCRIPT>create_link(35);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp36"></A><A NAME="3450"></A>
Used without discipline, C++ can lead to code that is incomprehensible, unmaintainable, inextensible, inefficient, and just plain <NOBR>wrong.<SCRIPT>create_link(36);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp37"></A><A NAME="1711"></A>
The trick is to discover those aspects of C++ that are likely to trip you up and to learn how to avoid them. That is the purpose of this book. I assume you already know C++ as a <I>language</I> and that you have some experience in its use. What I provide here is a guide to using the language <I>effectively</I>, so that your software is comprehensible, maintainable, extensible, efficient, and likely to behave as you <NOBR>expect.<SCRIPT>create_link(37);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp38"></A><A NAME="1712"></A>
The advice I proffer falls into two broad categories: general design strategies, and the nuts and bolts of specific language <NOBR>features.<SCRIPT>create_link(38);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp39"></A><A NAME="1713"></A>
<A NAME="p2"></A>The design discussions concentrate on how to choose between different approaches to accomplishing something in C++. How do you choose between inheritance and templates? Between templates and generic pointers? Between public and private inheritance? Between private inheritance and layering? Between function overloading and parameter defaulting? Between virtual and nonvirtual functions? Between pass-by-value and pass-by-reference? It is important to get these decisions right at the outset, because an incorrect choice may not become apparent until much later in the development process, at which point its rectification is often difficult, time-consuming, demoralizing, and <NOBR>expensive.<SCRIPT>create_link(39);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp40"></A><A NAME="1714"></A>
Even when you know exactly what you want to do, getting things just right can be tricky. What's the proper return type for the assignment operator? How should <CODE>operator</CODE> <CODE>new</CODE> behave when it can't find enough memory? When should a destructor be virtual? How should you write a member initialization list? It's crucial to sweat details like these, because failure to do so almost always leads to unexpected, possibly mystifying, program behavior. More importantly, the aberrant behavior may not be immediately apparent, giving rise to the specter of code that passes through quality control while still harboring a variety of undetected bugs — ticking time-bombs just waiting to go <NOBR>off.<SCRIPT>create_link(40);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp41"></A><A NAME="1715"></A>
This is not a book that must be read cover to cover to make any sense. You need not even read it front to back. The material is broken down into 50 Items, each of which stands more or less on its own. Frequently, however, one Item will refer to others, so one way to read the book is to start with a particular Item of interest and then follow the references to see where they lead <NOBR>you.<SCRIPT>create_link(41);</SCRIPT>
</NOBR></P>
<P><A NAME="dingp42"></A><A NAME="1716"></A>
The Items are grouped into general topic areas, so if you are interested in discussions related to a particular issue, such as memory management or object-oriented design, you can start with the relevant section and either read straight through or start jumping around from there. You will find, however, that all of the material in this book is pretty fundamental to effective C++ programming, so almost everything is eventually related to everything else in one way or <NOBR>another.<SCRIPT>create_link(42);</SCRIPT>
</NOBR></P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -