Ruminations on C++ A Decade of Programming Insight and Experience

by ;
  • ISBN13:


  • ISBN10:


  • Edition: 1st
  • Format: Paperback
  • Copyright: 1996-08-07
  • Publisher: Addison-Wesley Professional

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $34.99 Save up to $8.75
  • Buy Used


Supplemental Materials

What is included with this book?


Here is the kind of wisdom that can only be achieved through years of immersion in C++. Coming from authors who began C++ programming in its earliest days, this book will help you understand the why and not just the how of C++. Ranging far and wide in the field, the book explores fundamental ideas, demonstrates why inheritance is such a powerful concept, discusses the most effective use of templates, and explains how to design with the Standard Template Library. Each example demonstrates how to solve a particular programming problem, and the section devoted to tricks of the trade will boost your programming skills.

Author Biography

Andrew Koenig is a member of the Large-Scale Programming Research Department at AT&T's Shannon Laboratory, and the Project Editor of the C++ standards committee. A programmer for more than 30 years, 15 of them in C++, he has published more than 150 articles about C++, and speaks on the topic worldwide.

Barbara E. Moo is an independent consultant with 20 years' experience in the software field. During her nearly 15 years at AT&T, she worked on one of the first commercial products ever written in C++, managed the company's first C++ compiler project, and directed the development of AT&T's award-winning WorldNet Internet service business.


Table of Contents

First Try
Doing it without Classes
Why was it Easier in C++?
A Bigger Example
Why I Use C++
The Problem
History and Context
Automatic Software Distribution
Enter C++
Recycled Software
Why I Work on C++
The Success of Small Projects
Machines Should Work for People
Living in the Real World
Classes and Inheritance
Checklist for Class Authors
Surrogate Classes
The Problem
The Classical Solution
Virtual Copy Functions
Defining a Surrogate Class
Handles: Part 1
The Problem
A Simple Class
Attaching a Handle
Getting at the Object
Simple Implementation
Use-Counted Handles
Copy on Write
Handles: Part 2
Separating the use Count
Abstraction of use Counts
Access Functions and Copy on Write
An Object-Oriented Program
The Problem
An Object-Oriented Solution
Handle Classes
Extension 1: New Operations
Extension 2: New Node Types
Reflections 29
The Problem
Designing the Interface
A Few Loose Ends
Testing the Interface
Combining Pictures
Analysis of a Classroom Exercise: Part 2
Exploiting the Structure
Table of Contents provided by Publisher. All Rights Reserved.


Origins Early in 1988, about when I had finished writingC Traps and Pitfalls, Bjarne Stroustrup told me that he had just been invited to join the editorial board of a new magazine called theJournal of Object-Oriented Programming(JOOP). The magazine was intended to fit between the conventional academic journals and the magazines that are mostly product reviews and advertising. They were seeking a C++ columnist; was I interested? C++ was just beginning to become an important influence on the programming community. Usenix had recently held its first C++ workshop, in Santa Fe, New Mexico.They had expected 50 people; more than 200 showed up. Many more would hop on the C++ bandwagon, which meant that the community would need an articulate, reasoned voice to speak against the torrent of hype that was sure to come. It would need someone who could make clear the difference between hype and substance and keep a cool head in all the turmoil. I took the offer anyway. I am writing these words while thinking about my sixty-third column forJOOP. The column has appeared in every issue but two, during which time I badly needed a break and was lucky enough to be able to get Jonathan Shopiro to take my place. On a third occasion, I wrote only the introduction to the column, stepping aside for the distinguished Danish computer scientist Bjorn Stavtrup. In addition, Livleen Singh talked me into writing a column for the quarterlyC++ Journal, which lasted six issues before folding, and Stan Lippman cajoled me into doing a column for theC++ Reportwhen it changed from a newsletter into a full-fledged magazine. Adding my 29C++ Reportcolumns to the others brings the total to 98. That''s a lot of stuff to be scattered in periodicals all over the place.If the articles are useful individually, they should be evenmore useful when collected.In consequence, Barbara and I (mostly Barbara) have gone back over the columns, selected the best, and added to or rewritten them as needed for coherence and continuity. Just what the world needs--another C++ book Now that you know why the book exists, let me tell you why you should read it instead of some other C++ book. Goodness knows, there are enough of them; why pick this one? The first reason is that I think you''ll enjoy it. Most C++ books don''t have that in mind: They are curriculum-based. Enjoyment is secondary at best. Magazine columns are different. I suppose there must be some people out there who thumb through a copy ofJOOPin a bookstore and skim my column before deciding whether to buy the magazine, but it would be arrogant to think that there are more than a few. Most readers will be seeing my column after they''ve already paid for it, which means that they have a completely free choice about whether to read it or not. So each column has to be worth reading on its own. This book contains no long, boring discussions of obscure details. Beginners are not intended to be able to learn C++ from this book alone. A few people, who already know several programming languages thoroughly, and who have figured out how to infer the rules for a new language by reading code, will be able to use this book to get an overview of C++. Most readers starting from scratch would do well to readThe C++ Programming Language(Addison-Wesley 1991)by Bjarne Stroustrup, or Stan Lippman''sC++ Primer(Addison-Wesley 1991), and then read this book. This is a book about ideas and techniques, not details. If you want to find out how to make virtual base classes do double reverse backflips, you will have to turn elsewhere.What you will find here is lots of code to read.Try the examples for yourself. Classroom experience indicates that getting these programs to run and then modifying them is a good way to cement your understanding. For those who prefer to start with working code, we have made available selected examples from the book by anonymous FTP fromftp.aw.comin directorycseng/authors/koenig/ruminations. If you know some C++ already, I think that this book will not only entertain but also enlighten you. This is the second reason to read it. My intent isn''t to teach C++ per se. Instead, I want to show you how to think about programming in C++, and how to look at problems and express a solution in C++. Knowledge can be acquired systematically; wisdom cannot. Organization Although I intended each column to stand alone, I believe that the collection will be easier and more enjoyable to read when grouped by concept. The book is therefore divided into six parts. Part I is an extended introduction to themes that will pervade the rest of the book. You won''t find much code, but the ideas of abstraction and pragmatism explored there underlie both this book and, more important, the design of C++ and strategies for its effective use. Part II looks at inheritance and object-oriented programming, which most people think are the most important ideas in C++. You will learn why inheritance is important and what it can do.You will also learn why it can be useful to conceal inheritance from its users and when to avoid inheritance altogether. Part III explores templates, whichIthink constitute the most important idea in C++. The reason I think templates are so important is that they provide a particularly powerful kind of abstraction. Not only do templates allow the construction of containers that know almost nothing about the types of what they will contain, but they make it possible to abstract away things far more general than just types. One reason that inheritance and templates are important is that they are ways of extending C++ without waiting (or paying) for people to produce new languages and compilers. The way to organize such extensions is through class libraries. Part IV talks about libraries--both their design and use. With the basics well understood, we can look at some specialized programming techniques in Part V. Here you will find ways to tie classes inextricably together, as well as ways to keep them as far apart as possible. Finally, in Part VI, we turn back for a last look at the terrain we have covered. Compilation and editing One artifact of these papers having been written over a number of years is that they do not always use all the current features of the language.This raises a problem: Do we rewrite the columns as if full-fledged ISO C++ were the norm when the standard hasn''t been approved yet?Or do we deliberately write in an archaic style? As with so much else in C++, we compromised. Where the original column was simply incorrect--either in light of how the language has changed since the column was written or because of a change in our understanding of how things should be--we''vefixed it. A particularly pervasive example is our use ofconstthe importance of which has steadily grown in our understanding sinceconstentered the language. On the other hand, for instance, lots of examples here useintto represent true or false values, even though the standards committee has acceptedboolas a built-in data type. The reasoning is that the columns were written that way originally, usingintfor such values will still work, and it will be years before most compilers supportbool. Acknowledgments In addition to publishing our ideas inJOOP, theC++ Report, and theC++ Journal, we refined them through giving talks (and listening to students) in many places. Particularly noteworthy were the conferences organized by the Usenix Association and by SIGS Publications, publishers ofJOOPand theC++ Report. In addition, there are the weeklong courses that the two of us have taught at Stanford University under the auspices of the Western Institute in Computer Science, and at Bell Labs for members of the Acoustics Research Laboratory and Network Services Research Laboratory, as well as several courses and lectures that

Rewards Program

Reviews for Ruminations on C++ A Decade of Programming Insight and Experience (9780201423396)