⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ecprefac.htm

📁 一个非常适合初学者入门的有关c++的文档
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">
<HTML LANG="EN">
<HEAD>
<title>Effective C++, 2E | Preface</TITLE>
<LINK REL=STYLESHEET HREF=../INTRO/ECMEC.CSS>

<SCRIPT LANGUAGE="Javascript" SRC="../JAVA/COOKIE.JS"></SCRIPT>
<SCRIPT LANGUAGE="Javascript">var imagemax = 0; setCurrentMax(0);</SCRIPT>
<SCRIPT LANGUAGE="Javascript" SRC="../JAVA/DINGBATS.JS"></SCRIPT>
<SCRIPT LANGUAGE="Javascript">var dingbase = "ECPREDIR.HTM"; var dingtext = "EC++ Preface, P"; if (self == top) {
 top.location.replace(dingbase + this.location.hash);
}</SCRIPT>

</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" ONLOAD="setResize()">
<!-- SectionName="EC++ Preface" -->
<DIV ALIGN="CENTER"><FONT SIZE="-1">Back to <A HREF="./ECDED_FR.HTM" TARGET="_top">Dedication</A> &nbsp;&nbsp;<BR>&nbsp;&nbsp;Continue to <A HREF="./ECACK_FR.HTM" TARGET="_top">Acknowledgments</A></FONT></DIV>


<P><A NAME="dingp1"></A><A NAME="pxiii"></A><FONT ID="egtitle">Preface</FONT><SCRIPT>create_link(1);</SCRIPT>
</P>

<A NAME="32"></A>
<P><A NAME="dingp2"></A>
This book is a direct outgrowth of my experiences teaching C++ to professional programmers. I've found that most students, after a week of intensive instruction, feel comfortable with the basic constructs of the language, but they tend to be less sanguine about their ability to put the constructs together in an effective manner. Thus began my attempt to formulate short, specific, easy-to-remember guidelines for effective software development in C++: a summary of the things experienced C++ programmers almost always do or almost always avoid <NOBR>doing.<SCRIPT>create_link(2);</SCRIPT>
</NOBR></P>
<A NAME="291"></A>
<P><A NAME="dingp3"></A>
I was originally interested in rules that could be enforced by some kind of <CODE>lint</CODE>-like program. To that end, I led research into the development of tools to examine C++ source code for violations of user-specified conditions.<A HREF="#1316"><sup>1</sup></A> Unfortunately, the research ended before a complete prototype could be developed. Fortunately, several commercial C++-checking products are now available. (You'll find an overview of such products in <A HREF="../MAGAZINE/TO_FRAME.HTM" TARGET="_top">the article on static analysis tools</A> by me and Martin <NOBR>Klaus.)<SCRIPT>create_link(3);</SCRIPT>
</NOBR></P>
<A NAME="331"></A>
<P><A NAME="dingp4"></A>
Though my initial interest was in programming rules that could be automatically enforced, I soon realized the limitations of that approach. The majority of guidelines used by good C++ programmers are too difficult to formalize or have too many important exceptions to be blindly enforced by a program. I was thus led to the notion of something less precise than a computer program, but still more focused and to-the-point than a general C++ textbook. The result you now hold in your hands: a book containing 50 specific suggestions on how to improve your C++ programs and <NOBR>designs.<SCRIPT>create_link(4);</SCRIPT>
</NOBR></P>
<A NAME="55"></A>
<P><A NAME="dingp5"></A>
In this book, you'll find advice on what you should do, and why, and what you should not do, and why not. Fundamentally, of course, the whys are more important than the whats, but it's a lot more conve<A NAME="pxiv"></A>nient to refer to a list of guidelines than to memorize a textbook or <NOBR>two.<SCRIPT>create_link(5);</SCRIPT>
</NOBR></P>
<A NAME="212"></A>
<P><A NAME="dingp6"></A>
Unlike most books on C++, my presentation here is not organized around particular language features. That is, I don't talk about constructors in one place, about virtual functions in another, about inheritance in a third, etc. Instead, each discussion in the book is tailored to the guideline it accompanies, and my coverage of the various aspects of a particular language feature may be dispersed throughout the <NOBR>book.<SCRIPT>create_link(6);</SCRIPT>
</NOBR></P>
<A NAME="57"></A>
<P><A NAME="dingp7"></A>
The advantage of this approach is that it better reflects the complexity of the software systems for which C++ is often chosen, systems in which understanding individual language features is not enough. For example, experienced C++ developers know that understanding inline functions and understanding virtual destructors does not necessarily mean you understand inline virtual destructors. Such battle-scarred developers recognize that comprehending the <I>interactions</I> between the features in C++ is of the greatest possible importance in using the language effectively. The organization of this book reflects that fundamental <NOBR>truth.<SCRIPT>create_link(7);</SCRIPT>
</NOBR></P>
<A NAME="56"></A>
<P><A NAME="dingp8"></A>
The disadvantage of this design is that you may have to look in more than one place to find everything I have to say about a particular C++ construct. To minimize the inconvenience of this approach, I have sprinkled cross-references liberally throughout the text, and a comprehensive index is provided at the end of the <NOBR>book.<SCRIPT>create_link(8);</SCRIPT>
</NOBR></P>
<A NAME="373"></A>
<P><A NAME="dingp9"></A>
In preparing this second edition, my ambition to improve the book has been tempered by fear. Tens of thousands of programmers embraced the first edition of <I>Effective C++</I>, and I didn't want to destroy whatever characteristics attracted them to it. However, in the six years since I wrote the book, C++ has changed, the C++ library has changed (see <A HREF="./EC7_FR.HTM#8392" TARGET="_top">Item 49</A>), my understanding of C++ has changed, and accepted usage of C++ has changed. That's a lot of change, and it was important to me that the technical material in <I>Effective C++</I> be revised to reflect those changes. I'd done what I could by updating individual pages between printings, but books and software are frighteningly similar &#151; there comes a time when localized enhancements fail to suffice, and the only recourse is a system-wide rewrite. This book is the result of that rewrite: <I>Effective C++</I>, Version <NOBR>2.0.<SCRIPT>create_link(9);</SCRIPT>
</NOBR></P>
<A NAME="507"></A>
<P><A NAME="dingp10"></A>
Those familiar with the first edition may be interested to know that every Item in the book has been reworked. I believe the overall structure of the book remains sound, however, so little there has changed. Of the 50 original Items, I retained 48, though I tinkered with the word<A NAME="pxv"></A>ing of a few Item titles (in addition to revising the accompanying discussions). The retired Items (i.e., those replaced with completely new material) are numbers 32 and 49, though much of the information that used to be in Item 32 somehow found its way into the revamped <A HREF="./EC1_FR.HTM#1790" TARGET="_top">Item 1</A>. I swapped the order of Items 41 and 42, because that made it easier to present the revised material they contain. Finally, I reversed the direction of my inheritance arrows. They now follow the almost-universal convention of pointing from derived classes to base classes. This is the same convention I followed in my 1996 book, <A HREF="../MEC/INDEX.HTM" TARGET="_top"><I>More Effective C++</I></A>.<SCRIPT>create_link(10);</SCRIPT>
</P>
<A NAME="516"></A>
<P><A NAME="dingp11"></A>
The set of guidelines in this book is far from exhaustive, but coming up with good rules &#151; ones that are applicable to almost all applications almost all the time &#151; is harder than it looks. Perhaps you know of additional guidelines, of more ways in which to program effectively in C++. If so, I would be delighted to hear about <NOBR>them.<SCRIPT>create_link(11);</SCRIPT>
</NOBR></P>
<A NAME="35"></A>
<P><A NAME="dingp12"></A>
On the other hand, you may feel that some of the Items in this book are inappropriate as general advice; that there is a better way to accomplish a task examined in the book; or that one or more of the technical discussions is unclear, incomplete, or misleading. I encourage you to let me know about these things, <NOBR>too.<SCRIPT>create_link(12);</SCRIPT>
</NOBR></P>
<A NAME="41"></A>
<P><A NAME="dingp13"></A>
<NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>&deg;</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=dknuth" onMouseOver="self.status='Donald Knuth Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top">Donald</NOBR> Knuth</A> has a long history of offering a small reward to people who notify him of errors in his books. The quest for a perfect book is laudable in any case, but in view of the number of bug-ridden C++ books that have been rushed to market, I feel especially strongly compelled to follow Knuth's example. Therefore, for each error in this book that is reported to me &#151; be it technical, grammatical, typographical, or otherwise &#151; I will, in future printings, gladly add to the acknowledgments the name of the first person to bring that error to my <NOBR>attention.<SCRIPT>create_link(13);</SCRIPT>
</NOBR></P>
<A NAME="39"></A>
<P><A NAME="dingp14"></A>
Send your suggested guidelines, your comments, your criticisms, and &#151; sigh &#151; your bug reports <NOBR>to:<SCRIPT>create_link(14);</SCRIPT>
</NOBR></P><Dl><A NAME="36"></A>
<A NAME="dingp15"></A>
<DD>Scott Meyers
<DD>c/o Publisher, Corporate and Professional Publishing
<DD>Addison Wesley Longman, Inc.
<DD>1 Jacob Way
<DD>Reading, MA 01867
<DD>U. S. A.<SCRIPT>create_link(15);</SCRIPT>
</DL>
<A NAME="40"></A>
<P><A NAME="dingp16"></A>
Alternatively, you may send electronic mail to <A HREF="mailto:ec++@awl.com">ec++@awl.com</A>.<SCRIPT>create_link(16);</SCRIPT>
</P>
<A NAME="45"></A>
<P><A NAME="dingp17"></A>
<A NAME="pxvi"></A>I maintain a list of changes to this book since its first printing, including bug-fixes, clarifications, and technical updates. This list is available at the <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>&deg;</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=booke" onMouseOver="self.status='Addison Wesley Web Site for Effective C++'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>Effective C++</I> World Wide Web site</A>.</NOBR> If you would like a copy of this list, but you lack access to the World Wide Web, please send a request to one of the addresses above, and I will see that the list is sent to <NOBR>you.<SCRIPT>create_link(17);</SCRIPT>
</NOBR></P>
<A NAME="44"></A>

<A NAME="709"></A>
<TABLE WIDTH="100%"><TR>
<TD VALIGN="TOP"><NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>&deg;</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=smeyers " onMouseOver="self.status='Scott Meyers Home Page'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top">Scott</NOBR> Douglas Meyers</A><BR><IMG SRC="../INTRO/IMAGES/GRAPHICS/SIG.GIF" WIDTH=215 HEIGHT=70 BORDER=0 ALT="Scott Meyers"></TD>
<TD VALIGN="TOP" ALIGN="RIGHT">Stafford, Oregon<BR>July 1997</TD>
</TR></TABLE>

<A NAME="28"></A>

<DIV ALIGN="CENTER"><FONT SIZE="-1">Back to <A HREF="./ECDED_FR.HTM" TARGET="_top">Dedication</A> &nbsp;&nbsp;<BR>&nbsp;&nbsp;Continue to <A HREF="./ECACK_FR.HTM" TARGET="_top">Acknowledgments</A></FONT></DIV>

<HR WIDTH="100%">
<A NAME="dingp18"></A><A NAME="1316"><sup>1</sup> You can find an overview of the research at the <NOBR><FONT COLOR="#FF0000" SIZE="-2"><B>&deg;</B></FONT><A HREF="http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=booke" onMouseOver="self.status='Addison Wesley Web Site for Effective C++'; return true" onMouseOut="self.status = self.defaultStatus" TARGET="_top"><I>Effective</NOBR> C++</I> World Wide Web site</A>.<SCRIPT>create_link(18);</SCRIPT>
<BR>
<A HREF="#291">Return</A>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -