Introduction to the CD

Welcome to the Effective C++ CD!

I know you're in a hurry, so I'll get right to the point. Please read this entire document. It describes unique features (like the "°" symbol and the "" symbol) and provides important tips (such as how to make bookmarking work). It also contains:

Reading about these topics won't take that long, and besides, you only need to do it once.

Background

I've been interested in making my C++ books electronically available for many years, but it became practical only recently. The emergence of °HTML as a standard for representing on-line information eliminated the problem of choosing a distribution format, and the dominance of web browsers from °Netscape and °Microsoft made it possible to restrict the platforms on which electronic documents had to be tested.1 In addition, the latest versions of these browsers support features that can lead to a truly compelling reading experience.

Still, I'm from the Old School of publishing: I like printed books. I like being able to jot notes in the margins, I like being able to fold down the edges of important pages, and I especially like the look of text on paper. (Printed text may have a resolution of 2000 dpi or more, but computer monitors are lucky to muster a twentieth of that.) Most important of all, I like the fact that books stand by themselves; you don't need a computer to read them. Some people believe printed books will go the way of the dinosaur, but I'm not one of them.

At the same time, printed books are limited in ways electronic books aren't. Printed books can be heavy and bulky, but a single CD can hold thousands of pages of text. It's hard to search printed books, but electronic books can be searched in many ways. It's difficult to link hardcopy books together, but books in HTML are designed to be linked together (both by their authors and by their readers). Most printed books are limited to a single ink color, but electronic books can use scores of colors as easily as they use one. Printed books are restricted to text and static images, but electronic books can add animations, movies, sounds, and programs. Printed books present the same interface to everybody, but electronic books can be tailored to the preferences of their readers.

Hardcopy and electronic books are simply different. They don't compete with one another, they complement one another. I know from personal experience that sometimes I want a printed book, but other times I want an electronic version of the same information. As the author of Effective C++ and More Effective C++, I've had access to (and used) both forms for years. With this CD, I'm finally able to offer you the same flexibility I've enjoyed since 1991.

Technical Content

This CD features copies of both Effective C++, Second Edition, and More Effective C++, but that encompasses more material than you may think. Each book has always offered extensive internal cross references, but on this CD I was able to add dozens of cross references between the books. In onMouseOver = "self.status = 'Link to Item 10 of Effective C++'; return true" onMouseOut = "self.status = self.defaultStatus">Item 10 of Effective C++, for example, I explain how you might write a custom version of operator new, but I cover related memory management material in onMouseOver = "self.status = 'Link to Item 8 of More Effective C++'; return true" onMouseOut = "self.status = self.defaultStatus">Item 8 of More Effective C++. There are now links between these Items, and I can't tell you how happy I was to be able to add them. I've wanted to put them there ever since I wrote More Effective C++, but I couldn't do it in the printed books, because I was unwilling to assume that a reader of one book had access to the other. With both books on this CD, that issue vanished, and I was thrilled to be able to add the many between-book links that have always existed in my mind.

This CD also contains a comprehensive index of the material in Effective C++ and More Effective C++. Formed by merging the three independent indices found in the paper books, it provides an easy way to find material on any topic in either (or both) books. However, the index is only one way to find what you're looking for. We've gone to great lengths to facilitate searching the CD, so you're no longer constrained by what I decided was worth indexing. If a word or phrase appears anywhere on this CD (except as a stop word), you can find it.

In addition to the books, I've included several magazine articles that build on material covered in Effective C++ or More Effective C++. I wrote or helped write some of the articles, but others — notably those on exception handling — were written by such luminaries as °Tom Cargill, °Jack Reeves, and °Herb Sutter. I added links among these articles and my books, and I hope you'll agree that the result is greater than the sum of its parts.

Finally, you'll find some links between material on this CD and related material on the Internet. In essence, this CD is a web site, and as such it's only natural that it contains links to other places in cyberspace. As °John Donne might have put it, no web site is an island, entire of itself. This CD, though functionally self-contained, is no exception to that rule. (See below for information on how links to the Internet are handled.)

Much to my regret, you won't find a copy of the official °ISO/°ANSI standard for C++ on this CD. I wanted to include a copy, but it turned out that the attendant licensing fees would have increased the price of the CD by 25%-30%, and I just didn't think it was worth it. Never fear, however. I've provided the following link to a web-hosted copy of °the latest publicly available draft of the C++ standard. That's not as convenient as having the standard on this CD, of course, but it's almost as good, and it's a lot less expensive.

Navigating the CD

You're never more than two clicks away from anything on this CD. Furthermore, you've always got immediate access to both books, the Books' Index, the collection of magazine articles, the comprehensive search engine (described below), control over the configuration of your viewing preferences (also described below), this Introduction, and the CD's Home Page.

The key to this access is the column at the left of your browser window, the CD's Navigation Area. Regardless of where you are on the CD, clicking on the appropriate button in the Navigation Area always takes you to the Effective C++ Home Page, the More Effective C++ Home Page, or the Magazine Articles Home Page. Each of these pages displays the corresponding table of contents, so from there you can jump directly to any book Item or magazine article.

For example, suppose you're somewhere — anywhere — on the CD and you're overcome with an urge to read onMouseOver = "self.status = 'Link to EC++ Item 22: Prefer pass-by-reference to pass-by-value'; return true" onMouseOut = "self.status = self.defaultStatus">Item 22 of Effective C++. No problem, just click on the Effective C++ button in the Navigation Area, then select onMouseOver = "self.status = 'Link to EC++ Item 22: Prefer pass-by-reference to pass-by-value'; return true" onMouseOut = "self.status = self.defaultStatus">Item 22 from the book's table of contents. Or suppose you just have to reread my magazine article on counting objects. Simply click on the Magazine Articles button in the Navigation Area, then choose that article from the list.

If you don't know exactly where you want to go, you'll probably want to search for the information you desire. As you'll soon see, there are different ways to search, and you have constant access to all of them. The Navigation Area gives you direct access to the Books' Index and the search applet, and of course your browser's built-in search command is always available.

If you have access to a printed copy of Effective C++ or More Effective C++, you may find it convenient to jump to particular book pages. That's easy to do. The Navigation Area for each book contains a field where you can enter the page number you want. Just type the number and hit Enter (or click on the "GO" button). Voilá! You'll be there. (More or less. Remember that your browser determines line breaks on the fly.) To jump to page 99 of More Effective C++, for example, go to the Home Page for that book, type 99 in the "GO" field in the Navigation Area, and hit Enter. That's all there is to it.

I've put thousands of links on this CD, so it's natural to worry that after jumping among book Items, magazine articles, bookmarks (see below), and various CD-related documents (such as this one), you'll lose track of where you are. Relax. The color of the Navigation Area changes depending on where you are, as does the image at the top of the Navigation Area and the caption below the image. You'll quickly learn to recognize your surroundings without even thinking about it.

Searching

There are three ways to search for information on this CD:

Generally speaking, you should use the Books' Index if you want the benefits of a human-compiled index and you know that the information you're looking for is in Effective C++ or More Effective C++. Use a browser-based search if you know which file contains the information you're looking for and you have a specific string you want to find. Use the search applet if you need to search the entire CD.

Setting Your Preferences

Call me an anarchist, but when it comes to accessing technical information, I just don't believe that one size fits all. Not one size window, not one size font, not one size image, not one size file. Your window system and browser let you control the window and font sizes you see, but to gain greater control over the appearance and behavior of the material on this CD, you'll need to take advantage of its configuration options.

The first thing you need to know is that each image on this CD is stored five times, each copy being a different size. As a general rule, the bigger the size of your screen and the higher the resolution of your graphics card, the larger the image you'll want to view. Of course, what really matters is what looks good to you. If you like tiny images on a big monitor, or if you prefer huge images on a small screen, you won't see me making a fuss. I'm the anarchist, remember? Furthermore, if your preference changes (at any time, for any reason), you can make an on-the-spot modification to how images are displayed. Your new preference will take effect immediately.

To change the size of images displayed in text (i.e., outside the Navigation Area), select a different icon in the "Images" portion of the Navigation Area. Try it now to see how the following diagram changes. (The diagram itself shows the hierarchy of diagnostics classes in the standard C++ library. You'll find this diagram in onMouseOver = "self.status = 'Link to Item 49 of Effective C++'; return true" onMouseOut = "self.status = self.defaultStatus">Item 49 of Effective C++ and onMouseOver = "self.status = 'Link to Item 12 of More Effective C++'; return true" onMouseOut = "self.status = self.defaultStatus">Item 12 of More Effective C++.)

Similarly, you can adjust the size of the Navigation Area (including its associated images) by selecting different icons in the "Nav Size" portion of the Navigation Area — but don't do it yet! When you change the size of the Navigation Area, your browser will reload this file, and you'll find yourself back at the top of the document instead of here looking at this paragraph. This "feature" is built into browsers, and there's no way around it. (We tried. Believe me, we tried.)

Now that you know that changing the size of the Navigation Area will put you back at the top of the current document, go ahead and give the underlying °JavaScript some exercise by playing with the size of the Navigation Area. Later, when I describe paragraph-specific bookmarking, you'll see how you can mark your place in a document so you can return to it easily.

As I noted in my earlier discussion of your search options, there's a trade-off to be made between the size of an HTML File and the effectiveness of your browser's search command. This put me in a difficult position when designing the CD, because I didn't know what to optimize for. My solution was to kick the problem back to you. There are three copies of each book on this CD, each made up of files of different sizes. You thus have three choices for what I call the books' chunk size.

To select your preferred chunk size, just click on the appropriate icon in the "Chunks" portion of the Navigation Area. You say it's not obvious which icon is appropriate? Just move your cursor over each icon and wait a moment. Your browser will then provide you with a short description of the icon's meaning. Depending on your browser, the description will appear either in the browser's status bar or as a pop-up "tool tip"-like window.

Just as changing the size of the Navigation Area reloads files and puts you at the top of the current document (see above), changing your preferred book chunk size has a similar effect. However, if you change your preferred chunk size while inside a book, the page that's reloaded will be the book's table of contents, not the part of the book you're viewing. For example, if you're viewing Item 50 of Effective C++ and you change your chunk size setting, you'll find yourself back at the table of contents for Effective C++. In addition, the search applet will reinitialize itself the next time you perform a search. (All this reloading and reinitializing is necessary to make various links work the way they're supposed to, but I'll spare you the details. Suffice it to say we wouldn't inflict this on you if we knew of an easy way to avoid it.)

Links and Bookmarks

There are three kinds of links on this CD: links within a source of information (e.g., a link from one Item in Effective C++ to another Item in that same book), links between sources of information (e.g., from a magazine article to a book Item, from an Item in one book to an Item in the other book, or from a book to a magazine article), and links from the CD to sites on the Internet. Before following a link, it's often useful to know which of these three types you're confronting. This is particularly important when dealing with links to the Internet, as you probably don't want to follow them if you're working off-line.

There's nothing special about links within a source of information; they look just like normal links in your browser. So if you see a link to Item 14 and you're reading More Effective C++, you can rest assured that that's a link to Item 14 of the same book. Links to a book Item from outside that book prepend "E" or "M" to the Item number, depending on the book the link goes to. Hence, any reference to onMouseOver = "self.status = 'Link to Item 14 of Effective C++'; return true" onMouseOut = "self.status = self.defaultStatus">Item E14 will take you to Item 14 of Effective C++, while any reference to onMouseOver = "self.status = 'Link to Item 14 of More Effective C++'; return true" onMouseOut = "self.status = self.defaultStatus">Item M14 will take you to Item 14 of More Effective C++. The encoding doesn't get any more complicated than that, because links to magazine articles or this Introduction to the CD, etc., make their target explicit in the text making up the link.

Links to Internet sites are preceded by the "°" symbol. (You probably noticed this symbol preceding some links earlier in this file.) For example, here's a link to the web site for the °Wildlife Preservation Trust International, a conservation organization whose work I admire and support. However, it doesn't go directly to that site. Internet addresses change too often for that. Instead, like all links from this CD to the Internet, it goes to the Addison-Wesley web site, where it's translated into the correct °URL (to the best of AW's knowledge), and your browser is then automatically forwarded to the correct place in cyberspace. Going indirect via AW's web site for Internet links imposes a small performance penalty, but I think it's more than made up for by the fact that when a URL changes, all AW has to do is update its translation table, and your CD continues to work.

The flip side to the links on the CD is your ability to create links into the material on the CD. For example, suppose you'd like to create links from your corporate coding guidelines to some of my books' Items. That's easy to do, because each Item in each copy of each book (see above for information on selecting a preferred chunk size) is preceded by an HTML anchor (i.e., <a> tag). Such anchors are not enough, however, because sometimes you'd like to link to material in the middle of an Item. onMouseOver = "self.status = 'Link to Item 28 of More Effective C++'; return true" onMouseOut = "self.status = self.defaultStatus">Item M28 on Smart Pointers, for example, covers more than 20 pages in the printed book, so you might want to create a link that leads specifically to my discussion of onMouseOver = "self.status = 'How to emulate inheritance-based implicit type conversions among smart pointer types'; return true" onMouseOut = "self.status = self.defaultStatus">how to emulate inheritance-based implicit type conversions among smart pointer types. I address that topic over halfway through the Item, and it's reasonable to want to jump directly to that discussion.

To facilitate the creation of such links, each paragraph on this CD — whether in a book, a magazine article, or a document such as this — has an associated HTML anchor. (By "paragraph" here, I include Item titles, section headings, entries in tables of contents, etc.) That means you can create a link to any paragraph you like. To do it, however, you need to know the URL for each paragraph, and we've made getting that information easy.

You've doubtless noticed the odd-looking symbol at the end of each paragraph in this document. Every paragraph on the CD ends with one, and each paragraph's is a link to the beginning of that paragraph. Clicking on a thus jumps you to the beginning of the paragraph. That's not really why it exists, however (although it does provide a convenient way to skim forward a few paragraphs at a time — try it). Rather, it exists to make it easy to obtain the paragraph's unique URL.

To discover the URL for a particular paragraph, move your cursor over that paragraph's , then use your browser to copy the corresponding URL to the clipboard. (In Netscape Navigator, you do this by right-clicking the and selecting "Copy Link Location." Using Internet Explorer, you right-click the and select "Copy Shortcut." If you're on a Mac, you click-hold rather than right-click.) Once the paragraph's URL is on the clipboard, you can paste it into other HTML documents, and — shazaam! — you're linked to the paragraph. Diagrams and code examples lack symbols, so to link to one of those, just link to the preceding paragraph.

You'll need to use the symbols to create bookmarks, too, because your browser's standard bookmarking capability is, frankly, unreliable. That is, the usual "Add Bookmark" or "Add to Favorites" command will frequently not do what you want. The reasons for this are many and varied,2 but the bottom line is that use of your browser's standard bookmarking command can only lead to frustration and disappointment.

Nonetheless, bookmarking is a crucial capability, so the CD supports an alternative mechanism that does work. When you move your cursor over a paragraph's , a textual identification of the paragraph will automatically appear. This text is the bookmark description that will be generated if you bookmark that paragraph. For example, if you move your cursor over the at the end of this paragraph, you'll see "CD Intro, P63" appear after the . (The "P63" indicates that this is the 63rd paragraph in this document.)

If you're using Netscape Navigator, you bookmark a paragraph by right-clicking (or, on a Mac, click-holding) on the textual description following the paragraph's (not on the itself!), then selecting "Add Bookmark" from the resulting pop-up menu. If you're using Internet Explorer, you drag the paragraph description (the one that appears when you move your cursor over the paragraph's ) to your "Favorites" menu. Once you get used to it, you'll wish all web sites offered this kind of reliable, fine-grained control over bookmarking.

Because links and bookmarks refer to specific files, they take no notice of your chunk size preference. As a result, if you're using Chapter-length chunking while viewing Effective C++ and you create a link to or set a bookmark at, say, the third paragraph of Item 44, following that link or jumping to that bookmark will always take you to a Chapter-length file, even if you've since switched to Item-length or Book-length chunking. Oh well.

Annotating the CD (Sort Of)

Wouldn't it be great if you could add your own comments to the material on this CD? Sure it would. Alas, the "RO" in "CD-ROM" stands for "Read-Only," so modifying the files on the disc is tough. Furthermore, most web browsers are just that, browsers. They view web pages, they don't edit them. Of course, if you've chosen to copy this CD to a hard drive and if your web browser offers editing capabilities, you can modify the files in any way you choose. Still, the fact remains that, generally speaking, annotating the CD borders on the impossible.

I don't know how to cross that border, but here's one way to lean heavily against it. Create an HTML document containing the annotations you'd like to add to the CD. Using the paragraph-specific bookmarking capability described above, link each annotation to the paragraph to which it pertains. This is far from perfect, but it's better than nothing, and remember, those of us working on the CD are wrestling with a read-only medium and the constraints of the most popular browsers. Trust me when I tell you we're trying as hard as we can.

Running Off a Hard Drive

If you'd prefer to access the material on this CD from a hard drive, all you need to do is copy the files over. Be sure to preserve the directory structure during the copy. You can then invoke your browser on the copy of INDEX.HTM on your hard drive, and everything will work as if you were running off the CD.

Acknowledgments

If it takes a village to make a CD, among the more prominent villagers behind this disc are my colleagues at Addison-Wesley: Jason Jones, Marty Rabinowitz, John Wait, and Sarah Weaver. For months the five of us have debated design alternatives, wrestled with implementation difficulties, reviewed prototypes, plotted strategy, and otherwise laid siege to a project that too often resembled a °fifty-headed hundred-handed monster. Others at AW contributed to the project, but Jason, Marty, John, and Sarah were there on the front lines every day — often enduring both me and my harangues. I'm grateful to them for both their efforts and their forbearance.

To Jason Jones I owe a special debt. His heroic eleventh-hour efforts kept the CD on schedule, something I'd dismissed as impossible. Jason, thank you for proving me wrong.

The bulk of the translation into HTML was done by the folks at °Videomation Interactive. Their efforts give this product its unique look and feel, and I'm pleased to thank Jason Dawson, Razzaq Lodhia and their colleagues for helping us go where none of us had gone before.

Chris Peterson of Silver Beach Software took the search applet that was developed for the °Design Patterns CD and skillfully molded it into the version you find here. If you'd like to learn more about Chris' skills, contact him at kit@silverbeach.com.

Jeffrey Richter and Paul DiLascia offered quick responses to my pleas for help on autorun.inf files. So pathetic was my understanding, Paul sent me working source code — right before Thanksgiving! I was (and continue to be) quite thankful.

°Tom Cargill, °Martin Klaus, °Jack Reeves, and °Herb Sutter not only allowed me to include copies of C++ articles they'd published, in many cases they revised and updated those articles for presentation here. The CD is considerably enriched by those articles, and I'm indebted to these authors for their generosity.

Prototype versions of the CD were reviewed by Andrei Alexandrescu, Steve Clamage, Chris Cleeland, David Drysdale, Carolyn Duby, Bruce Eckel, David Goh, Michael Hoffman, Tim Johnson, Brian Kernighan, Martin Klaus, Barbara Moo, Rob Murray, Vivian Neou, John Peterson, Rajashree Purohit, Mark Rodgers, Bobby Schmidt, Ducky Sherwood, Martin Shoemaker, Herb Sutter and John Vlissides. Their detailed critiques and suggestions helped us make the CD both more useful and more usable. I am especially grateful to Tim Johnson for his superhuman efforts. From Legal Stuff through to the Books' Index, his keen observations led us to improve virtually every page on the disc. Once the CD came out, we were able to fix defects reported by the following sharp-eyed readers: Jason Dawson, David Holmes, Mark Rodgers, Chris Hill, Reed Meseck, Reid Rowlett, Bernd Mohr, Bobby Schmidt, William Reyes, Sarah Weaver, Fred Fluke and Ross Brattain. I thank them all for the dozens of ways in which they helped us bolster the quality of the CD.

My wife, Nancy L. Urbano, is by now somewhat inured to the monothematic outlook on life that consumes me during my work on book projects, but during preparation of this CD, I was much worse than usual. I don't know how she puts up with me.

Our dog, Persephone, loves me no matter what. That's one of many reasons she is, as °her web site proclaims, The Best Dog in the World.

Finally, I must acknowledge the infectious music of °The Cherry Poppin' Daddies' Zoot Suit Riot, a mainstay for me, Nancy, and The Best Dog in the World ever since we first heard it.

Reporting Bugs, Sending Comments, Making Suggestions, etc.

My colleagues and I have tried to make this CD as useful as possible, but electronic publishing is in its infancy, and I'm sure there are many things we could have done better. Please help us improve our efforts the next time around. If you find a shortcoming of any kind on this CD — be it visual, behavioral, functional, technical, grammatical, whatever — please bring it to my attention. If possible, I will correct it in future printings of the CD, and if you are the first person to report it, I will gladly add your name to the CD's acknowledgments.

In addition, I continue to collect guidelines for effective programming in C++. If you have suggestions for new guidelines, I'd be delighted if you'd share them with me. Send your suggested guidelines, as well as your comments on the CD, to ec++cd@awl.com, or ecppcd@awl.com if your email system does not support addresses with a "+" sign. If you prefer postal mail, please address your comments to:

Scott Meyers
c/o Editor-in-Chief, CEPUB Professional
Addison Wesley Longman, Inc.
One Jacob Way
Reading, MA 01867
U. S. A.
I maintain a list of changes to this CD since its first printing, including bug-fixes, clarifications, and technical updates. This list, along with other CD-related information (including a list of °platform-specific problems), is available at the °Addison-Wesley web site for this product. If you would like a copy of the list of changes to the CD, 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 you.

I hope you like the Effective C++ CD, and I especially hope you find it useful.

°Scott Douglas Meyers
Stafford, Oregon
December 1998

1Despite our best efforts to get this CD to behave in a uniform manner regardless of the browser or operating system you're using, different browsers do behave differently. Both Netscape and Microsoft make their browsers available for free, so I encourage you to try both °Navigator and °Internet Explorer . In addition, please check our list of °platform-specific problems for ideas on how to work around deficiences in specific browsers and browser versions.
Return

2Documents containing tables often yield incorrect bookmarks, and documents with frames almost always do. Furthermore, bookmarks simply record the most recently accessed URL, so they typically identify only which document you're reading, not where in the document you are. If you move around via searching or scrolling before creating a bookmark, for example, the bookmarked location will fail to reflect the searching and scrolling you did.
Return