找回密码
 注册
搜索
热搜: java php web
查看: 446|回复: 0

More Exceptional C++

[复制链接]
发表于 2009-10-25 00:11:54 | 显示全部楼层 |阅读模式


作者:Herb Sutter
出版日期:2001-12-17
出版社:其它
页数:279
ISBN:9780201704341
文件格式:PDF

The Greek philosopher Socrates taught by asking his studentsquestions–questions designed to guide them and help them drawconclusions from what they already knew, and to show them how thethings they were learning related to each other and to their existingknowledge. This method has become so famous that we now call it the“Socratic method.” From our point of view as students, Socrates’approach involves us, makes us think, and helps us relate and applywhat we already know to new information. This book takes a page fromSocrates, as did its predecessor, Exceptional C++ Sutter00. It assumesyou’re involved in some aspect of writing production C++ softwaretoday, and uses a question-answer format to teach you how to makeeffective use of standard C++ and its standard library with aparticular focus on sound software engineering in modern C++. Many ofthe problems are drawn directly from experiences I and others haveencountered while working with production C++ code. The goal of thequestions is to help you draw conclusions from things you already knowas well as things you’ve just learned, and to show how theyinterrelate. The puzzles will show how to reason about C++ design andprogramming issues–some of them common issues, some not so common; someof them plain issues, some more esoteric; and a couple because, well,just because they’re fun. This book is about all aspects of C++. Idon’t mean to say that it touches on every detail of C++–that wouldrequire many more pages–but rather that it draws from the wide paletteof the C++ language and library features to show how apparentlyunrelated items can be used together to synthesize novel solutions tocommon problems. It also shows how apparently unrelated parts of thepalette interrelate on their own, even when you don’t want them to, andwhat to do about it. You will find material here about templates andnamespaces, exceptions and inheritance, solid class design and designpatterns, generic programming and macro magic–and not just asrandomized tidbits, but as cohesive Items showing theinterrelationships among all of these parts of modern C++. What’s“More?” More Exceptional C++ continues where Exceptional C++ left off.This book follows in the tradition of the first: It delivers newmaterial, organized in bite-sized Items and grouped into themedsections. Readers of the first book will find some familiar sectionthemes, now including new material, such as exception safety, genericprogramming, and memory management techniques. The two books overlap instructure and theme, not in content. Where else does More ExceptionalC++ differ? This book has a much stronger emphasis on genericprogramming and on using the C++ standard library effectively,including coverage of important techniques such as traits andpredicates. Several Items provide in-depth looks at considerations tokeep in mind when using the standard containers and algorithms; many ofthese considerations I’ve not seen covered elsewhere. There’s a newsection and two appendixes that focus on optimization in single- andmultithreaded environments–issues that are now more than ever ofpractical consequence for development shops writing production code.Versions of most Items originally appeared in Internet and magazinecolumns, particularly as Guru of the Week GotW issues #31 to 62, and asprint columns and articles I’ve written for C/C++ Users Journal , Dr.Dobb’s Journal , the former C++ Report , and other publications. Thematerial in this book has been significantly revised, expanded,corrected, and updated since those initial versions, and this book(along with its de rigueur errata list available at [ahref=”http://www.gotw.ca” target=”new”>www.gotw.ca ) should betreated as the current and authoritative version of that originalmaterial. What I Assume You Know I expect that you already know thebasics of C++. If you don’t, start with a good C++ introduction andoverview. Good choices are a classic tome like Bjarne Stroustrup’s TheC++ Programming Language Stroustrup00, or Stan Lippman and Josee Lajoie’sC++ Primer, Third Edition Lippman98. Next, be sure to pick up a styleguide such as Scott Meyers’ classic Effective C++ books Meyers96Meyers97. I find the browser-based CD version Meyers99 convenient anduseful. How to Read This Book Each Item in this book is presented as apuzzle or problem, with an introductory header that resembles thefollowing: Item #: The Topic of This Puzzle Difficulty: X The topic tagand difficulty rating gives you a hint of what you’re in for. Note thatthe difficulty rating is my subjective guess at how difficult I expectmost people will find each problem, so you may well find that a “7″problem is easier for you than some “5″ problem. Since writingExceptional C++ , I’ve regularly received e-mail saying that “Item #Nis easier (or harder) than that!” It’s common for different people tovote “easier!” and “harder!” for the same Item. Ratings are personal;any Item’s actual difficulty for you really depends on your knowledgeand experience and could be easier or harder for someone else. In mostcases, though, you should find the rating to be a good rule-of-thumbguide to what to expect. You might choose to read the whole book frontto back; that’s great, but you don’t have to. You might decide to readall the Items in a section together because you’re particularlyinterested in that section’s topic; that’s cool, too. Except wherethere are what I call a “miniseries” of related problems which you’llsee designated as “Part 1,” “Part 2,” and so on, the Items are prettyindependent, and you should feel free to jump around, following themany cross-references among the Items in the book, as well as somereferences to Exceptional C++. The only guidance I’ll offer is that theminiseries are designed to be read consecutively as a group; other thanthat, the choice is yours. Namespaces, Typename, References, and OtherConventions I make quite a few recommendations in this book, and Iwon’t give you guidelines that tell you to do something I don’t alreadydo myself. That includes what I do in my own example code throughoutthis book. I’ll also bow to existing practice and modern style, evenwhen it really makes no material difference. On that note, a word aboutnamespaces: In the code examples, if you see a using-directive at filescope in one example and at function scope in another example a fewpages or Items later, there’s no deeper reason than that’s what feltright and aesthetically pleasing to me for that particular case; forthe rationale, turn to Item 40. In the narrative text itself, I’vechosen to qualify standard library names with std:: when I want toemphasize that it’s the standard facility I’m talking about. Oncethat’s established, I’ll generally switch back to using the unqualifiedname. When it comes to declaring template parameters, I sometimes comeacross people who think that writing class instead of typename isold-fashioned, even though there’s no functional difference between thetwo and the standard itself uses class most everywhere. Purely forstyle, and to emphasize that this book is about today’s modern C++,I’ve switched to using typename instead of class to declare templateparameters. The only exception is one place in Item 33, where I quotedirectly from the standard; the standard says class, so I left it inthere. Unless I call something a “complete program,” it’s probably not.Remember that the code examples are usually just snippets or partialprograms and aren’t expected to compile in isolation. You’ll usuallyhave to provide some obvious scaffolding to make a complete program outof the snippet shown. Finally, a word about URLs: On the Web, stuffmoves. In particular, stuff I have no control over moves. That makes ita real pain to publish random Web URLs in a print book lest they becomeout of date before the book makes it to the printer’s, never mind afterit’s been sitting on your desk for five years. When I reference otherpeople’s articles or Web sites in this book, I do it via a URL on myown Web site, www.gotw.ca , which I can control and which contains justa straight redirect to the real Web page. If you find that a linkprinted in this book no longer works, send me e-mail and tell me; I’llupdate that redirector to point to the new page’s location (if I canfind the page again) or to say that the page no longer exists (if Ican’t). Either way, this book’s URLs will stay up-to-date despite therigors of print media in an Internet world. Whew. Herb Sutter Toronto,June 2001 020170434XP11292001

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|软晨网(RuanChen.com)

GMT+8, 2024-11-23 05:47

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表