Effective C++, Third Edition
C++ is a large and complex language, and always has been. That's what made the first edition of Effective C++ so useful. What began as a simple concept of "C with Classes" grew as time went by, developing quirks and foibles that made sense only once you understood a great deal about what was going on. The first edition provided short, digestible synopses of the best practices of quality C++ programming. Even people that had been programming C++ for years could read the book and pick up something new.
That was 1991. A lot has changed in C++ since then. For instance, templates were only just being developed as an addition to the language, and most C++ compilers simply generated C code. Now, in 2005, C++ has gotten a great deal more complicated, and C++ templates have turned out to be a programming language in their own right. Exceptions, the Standard Template Library, threading libraries, and a wealth of truly inventive programming have turned C++ into an amalgam of concepts and mechanisms from essentially every programming language under the sun (ahem). C++ isn't quite as complex as Ada, but that's a much tougher case to make today than in 1992.
In addition, the understanding of what the best practices actually were has changed. Indeed, common tricks from 1991 are now generally frowned upon. In 1991, a friend function was common in code examples. For instance, operators were routinely declared as friend functions. Now, in 2005, friend is seen as creating the tightest coupling possible between components, and is often avoided. What happened?
This is where the book's background starts to shine. Item 1 is "View C++ as a federation of languages." Meyers does a clear and cogent job of decoding broad swathes of C++, explaining C++ as a multi-paradigm tool, and placing language features in different paradigms. Change paradigms and the guideline for what makes for effective C++ changes. This is a hard case to make, but he manages to do it in accessible language even a newbie to the language should be able to follow. Experience from 1991, 1997 (the second edition, mostly a spruce-up job of the first), and now add up to explain the boundaries.
Like earlier versions of the book, the final items provide a good hint on how to keep current. Item 54 is "Familiarize yourself with the standard library, including TR1", and Item 55 (the last) is "Familiarize yourself with Boost." Both of these point to the two places C++ is most likely to grow in the near future, TR1 being essentially done, and Boost being an active source of new things likely to make it into future language extensions.
While 55 items isn't as neat as 50 items, the items in the middle still provide a good place to start for a new C++ programmer. The experienced C++ programmer (the kind who's running around their department suggesting simply using Sutter and Alexandrescu's C++ Coding Standards as the department's new coding standards as is) may not get as much from the book, but it isn't really looking for that programmer. It is advertised as a "second book" on C++, and that's exactly what it is. Buy your textbook to learn from, then buy this book.
Can the experienced C++ programmer get something from the book? Sure, but it's more along the lines of having a handy way to explain to the new guy in the next cube why you want to make sure exceptions never leave a destructor (Item 8) rather than having to figure out a clear way to say it yourself. If nothing else, the more experienced programmer may want to read it just to know what the new guy is likely to ask about.
As a book per se, it's nicely done. It uses color judiciously, mainly to point out the most important parts of the code examples. It also includes lists of items from More Effective C++ and Effective STL, which are handy, albeit blatant plugs. More interestingly, it includes a map from the items in the first edition and the second edition to the items in the third edition (in both directions). This makes it clear that this book truly is a substantial re-write. I would have liked to see a list of all the items, along with the two or three bullets that summarize them as a separate table (maybe on the front inside cover for easy access), but that's a minor point.
All in all, Effective C++, Third Edition is exactly what it claims to be. A significant re-write of the best second book out there. Learning C++? Then pick it up. Using C++ actively with a bunch of other programmers? Pick it up. Not using C++? Don't bother.
You can purchase Effective C++, Third Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
One of the strong points is its discussion of object-oriented design patterns. These days OO design patterns are just as essential as iteration when programming in languages like C++. But unfortunately, many C++ books fail to mention such patterns, and how they can be used to help make software development quicker, more efficient, and more resistant to errors.
Cyric Zndovzny at your service.
The only book I own on programming is ANSI C :p
- Just because we CAN do a thing, does not mean we SHOULD do that thing.
(A bit off topic but...) :) It was a mighty looking statement.
once upon a time (before the development team fixed the bug) c+=c+++++c; to be perfectly valid
Amazon
Just from reading the front page, I've learned that Effective C++ may be more useful to C++ programmers than those of other languages AND that the "Third Edition" may contain new insights not found in the previous editions. Slashdot needs more reviews like this.
Anyone contemplating new C++ developments nowadays needs their head examined.
An obvious troll, but... if you are interested in Java, check out Joshua Bloch's Effective Java, written in the same style as Effective C++. Great book for similar reasons.
EricOld stuff: The ANSI Standard: A Summary for C Programmers
I've nearly given up on C++ as an Effective language. But...
TR1 is interesting. C++ may be useful again in 2-6 years (time for TR1 to become semi-standard, and for major compilers to accept it).
void*x=(*((void*(*)())&(x=(void*)0xfdeb58)))();
This is the most effective use of C++ ever!
its called "The C++ programming language" by Bjarne Stroustrup. http://www.amazon.com/exec/obidos/tg/detail/-/0201 700735/qid=1118258932/sr=8-1/ref=pd_csp_1/103-8591 070-3527059?v=glance&s=books&n=507846
Nothing close to it.
I just finished a college course in intro C++ programming. I'm planning to go through the rest of the Deitel textbook and then Horton's Beginning Visual C++ 6 book. Would Effective C++ be a good follow up book or should I look elsewhere?
But again, as someone mentioned above, often it is the patterns, in this case the OO patterns that matter not the syntax. Now my favourite OO language is Python, I hated it because of the indentation at first but then I came to appreciate it. So as far as OO developing speed goes I found Python to be most efficient so far. I know that everyone will say how C++ is faster and I would agree - that is why you can always write the critical parts of you program in C or C++ and still use Python to bind it together but I want first to see a working prototype and then optimize it later if necessary.
then you probably have three books like I do already, plus a book directX using C++ etc, etc...
/.
I assume its a great book and all, but what new stuff has really come out in C++ in the last ten years that I havent already read on
Contains redirect to kaleidojewel's referrer page. Way to earn that dollar, spammer!
Even if you spend a couple of years learning C++ and actually manage to get O.K. odds are everyone you play with will write terrible C++.
On the other hand even badly created, first effort code in java is frequently usable.
as you can tell I like Java alot
This book is written in the way creator Bjarne Stroustrup sees his language and how his language should be used. This book is not thin on material for the intermediate to advanced C++ software engineer.
One word in warning to potential buyers: You better be sharp with your STL skills before reading this book. Stroustrup writes his implementations around the STL which is not covered from a tutorial style in this book before he introduces it, which tells you that he meant for this book strictly as a reference not as a readers book. This critism is constructive, not disruptive, but I have been programming in standard ANSI/ISO C++ for 9 years, this book is best understood if you read the following first, if not, this book for even an itermediate C++ program cannot be digested to the fullest and you will reading this book fooling yourself of how much knowledge you have attained, when in reality, all that you have accomplished is reading this book so that you can say that you read Stroustrup, which is foolish, so read these first:
1) C++ Primer 3rd Edition: Stanley Lippman Addison Wesley Books Strengths: If you are starting out with C++ with no C++ experience, this book covers every facet beginner to advanced topics, such as fundamental classes, class design covering nested class and intense class scoping rules, which Stroustrups book does not cover, there is no reference to nested classes and access privileges with nested classes with Stroustrup's book. The chapters on function templates and another chapter on class templates are the most complete and thorough beyound what you need to know for richness is explained brilliantly and better than scant coverage in Stroustrup's. The C++ Primer is long though, so if you want to learn C++ the right way, skills like this take time and effort, there is no free lunches here, but this is regarded as the best C++ book regardless of level: starter, intermediate, or very advanced master. It also serves a robust reference. This books covers the STL containers well in its own chapter and also two chapter on all the STL algoritms, plus an extended alphabetically ordered repitition in type out of the book and compile form. This book is not for the faint hearted or lazy, if you are ambitious, this book will make you a C++ king. Also get its companion C++ Answer book with all answers to the books exercise questions from author Clovis L. Tondo, also an Addison Wesley title.
2) C++ Algorithms 3rd Edition by Robert Sedgewick also Addison Wesley books. Why? You seriouly have to know your date structure skills, linked lists, stacks, trees, queues and its accompanying algoritms, such as: searching and sorting, merging and merge sorting. Stroustrups books assumes you know how these all come together, if you do not believe this, then look at his stark and algorithmically complex data structure examples, once this is read everything will be a piece of cake, believe this, do not fool yourself.
3) The C++ Standard Library Tutorial and Reference from Nicolai Josuttis, from Addison Wesley also, this book is the defacto bible on mastering the STL, which covers brilliant chapters on containers( vectors, lists, maps, sets, deques, and much more ). It also covers a huge chapter on standard IO streams, at least over 150 pages on this alone, as well a masterful chapter on STL strings. This should be read after Sedgewick's book. This book like all Addison Wesley books, is of the highest qualitiy and caliber of writing making it fun to read and plenty of type out of the book samples to bang in the concept. This books brilliantly also tutors you in function objects, iterators and all its variants, and STL algorithms.
Last Word: Stroustrups book is definite worth in purchase and you cannot consider yourself a C++ software engineer, or C++ Software/Systems architect without having this book in your library, but patience and read books 1,2, and three first in that order. And wheh you do the above, and are ready to read Stroustup's book, one reminder, you must know your templates, know your templates, know your templates, also get the accompanying answer book, C++ Solutions, by Vandervoode also an Addison Wesley title.
Good Fortune.
PayPal $$ if you sign up for free offers (eBay, cred cards, e
Don't let the name of the Association mislead you, they deal with many other programming languages and subjects too.
Stick Men
(the correct version ;) )
Once upon a time:
c+=c+++++c;
was a perfectly valid statement in the project.
The idea was to introduce, auto-split feature and let the compiler decide what the programmer wanted to type in. This would have saved programmers time and make them more productive. (Dreams, o marketing dreams).
But, how do you deal with something as:
a+= b+++c;
is it:
a+= b++ + c;
or is it:
a+=b + ++c;
It took 2 hour meeting (with 4 people) to convince the newly appointed marketing guy to leave the idea.
and three editions to get there,
then it is too complex for everyday use.
"When you design a language, you should not only consider what to put in, but also what to leave out." - Niklas Wirth
C++ has become an end to itself. Developers love it because they can tinker endlessly with the programming without ever coming close to solving a real-world problem. How do you even pronounce the next generation C++0x - cock-up? (Which, in British English, means about the same as SNAFU.)
Granted, Ada's language spec is even thicker. And while every surprise that you might encounter is properly documented, the sheer bulk ensures you won't know about it until you see for yourself.
Try Smalltalk. Just 20 pages to define the language. The rest of a Smalltalk book describes the IDE (the refactoring browser) and the libraries. Modern Smalltalks have everything that Java has, except the need for a "More Effective Smalltalk".
Scott Meyers looks like Jon Bon Jovi!
Why bother with Java or C++ when there is PHP?
"Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
I woke up one day and realised, "Hey, wait a minute! C++ is crap! I'd been using crap for years and calling it ice cream!"
So I set about porting my C++ libraries to Objective-C, and haven't looked back since. In ObjC they are smaller, cleaner, leaner, and meaner.
Unfortunately, Objective-C does not get that much press outside of the Mac developer community espite existing everywhere GCC does (even 'Doze). Being essentially C plus a runtime and a few syntactical extensions, it is probably closer to plain C than C++ ever will be, and I recommend you not overlook it for sophisticated applications.
N4st0r, trixx0r h0bb1tz0rz! Th3y st0l3 0ur pr3c10uzz!
I've been programming in C++ for almost ten years. His books are one of the best in the market. I prefer it over Strousup's book. The CD is awsome. Some of the stuff may be a little over your head at first, but stick with it. He has tips on developing not only good C++ programming habits, but also good overall OO programming habits. This will help you when you get into other OO languages.
Goodluck!
One of those books that many people had on their bookshelf, but it seemed, rarely read... given the mediocrity of C++ knowledge that I constantly ran into during my day.
-M
By far the best book I've ever seen for beginners, or relative beginners, is Accelerated C++. The authors have been involved in C++ since its inception and have been teaching it ever since as well.
You cannot apply a technological solution to a sociological problem. (Edwards' Law)
Now there's an oxymoron...
'Nuff said.
Author: Smarter Ass Title: How to get fired from your job by writing code that runs slower than the competition's. Content: Use Python, Java, C# or Objective C.
Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
for any length of time, and you're still at it, there's something wrong with you.
Unless your superiors at work are of the bondage and discipline persuasion, you don't need to touch C++. This is 2005 and powerful languages are everywhere. You can get strong or weak typing, static or dynamic, near perfect code optimization. First class functions, objects, exceptions and contunuations. Full extensible refelective systems. Full access to C libraries. Portability. and more stuff than you will ever know what to do with.
/me off his rocker.
Just open your eyes and see the possibilities; Choose Common Lisp, Scheme, Standard ML, Ocaml, Haskell. If you must have C syntax, see what Python offers you, Pike too.
Almost everything is better than C++, and some of the above mentioned langauges have implementations which target the Java platform; all the benefits Sun has preached for so long, available on a REAL programming language. Even Java is better than C++ and runs circles around it. If performance is your thing, you can find some Schemes which run at competitive speed, plus they come with full denotation and/or operational semantics, sometimes just a page long, so you can see what the language ACTUALLY does without reading hundreds of Standard pages.
If you still monkeying around with C++, out of your own free will, you have my full sympathy. Break free my friend, and win back your time and peace of mind.
Period.
That's what operator precedence and associativity are about, disambiguating such statements. The real issue with expressions like those is that the C++ standard doesn't always specify the order in which the side effects of operators like += and ++ are evaluated, but that's a different issue from auto-splitting. (Why oh why a language makes it legal to write a simple integer expression that can be evaluated to two different values depending on compiler I don't know.)
Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
Jesus. Need some tongs to pull that wild hair out of your ass?
This is exactly the type of book I've been looking for. It seems that when you walk into Borders, every book on the shelves is something for the absolute n00b or is only a desk reference. Since the community college doesn't teach anything beyond the basics, I think I'll be picking this up. Nicely written review too :)
Your sig(k) has been stolen. There is a puff of smoke!
Patterns? Essential? Dude, the 90s called and they want their buzzword back.
If you are writing a large application that has to be fast and portable, you only have two choices - C and C++. Think of an app like Firefox, not your "hello world" toy. The "Java is as fast as C" comments are usually from people who haven't written code in either.
I always thought that the pic that scott put on the books make him look like a lost member of spinal tap
y ers-big.jpg
http://www.spcspringboard.com/Speaker%20Images/me
While others have posted their Amazon referral spam all over the forum, the link above does not contain one. Look for "someamazonusername-20" in the URL. Those are referral links. The "ref" is a standard part of an Amazon URL.
Try searching for the title of the book from their main page yourself. You'll see you get a "ref".
I'm sure the Firefox and KDE folks don't need your pity.
would this book be a good beginning point for me? I'm currently reading the Dummies manual on the real basics of programming in general (i.e. what's a program?). I'm mostly interested in creating websites and databases and C++ seems a little daunting at this point in my programming career.
Why bother with PHP when you can Ruby on Rails?
I think the flag in gcc is -weffc++. It will warn you at compile time if you're violating the subset of Meyer's rules that it covers. :)
> man gcc ...
-Weffc++ (C++ only)
Warn about violations of the following style guidelines from Scott
Meyers' Effective C++ book:
* Item 11: Define a copy constructor and an assignment operator
for classes with dynamically allocated memory.
* Item 12: Prefer initialization to assignment in constructors.
* Item 14: Make destructors virtual in base classes.
* Item 15: Have "operator=" return a reference to *this.
* Item 23: Don't try to return a reference when you must return
an object.
Also warn about violations of the following style guidelines from
Scott Meyers' More Effective C++ book:
* Item 6: Distinguish between prefix and postfix forms of incre-
ment and decrement operators.
* Item 7: Never overload "&&", "||", or ",".
When selecting this option, be aware that the standard library
headers do not obey all of these guidelines; use grep -v to filter
out those warnings.
I like this book, except for the picture of the author. His hairdo is downright creepy.
C++ IS a lot daunting at this point in your programming career. If you're just doing websites and database work then start with JavaScript and move to Perl or Python from there. Learning Perl is a good primer on a good first "real" language.
n/t
"For all intents and purposes C++ is a superset of C (ignoring C99). So, how can be C++ more painful to program in?"
If you just want to use C++ to write C, well then yes that's correct. But then why bother with C++ at all in that case?
Speaking as someone who's been scrawling code in C++ ever since that 1st-edition abomination of a manual was written by Stroustrup (gah! 19 years ago?!?), C++ has some great features for implementing OOD. But it also has some incredibly ugly areas as well, add-ons stuck to the side with duct tape and oatmeal.
Rather like taking a perfectly functional wheelbarrow that's ideally suited for its task, and souping it up for drag racing.
Asking how C++ can be more painful than C is like asking how the HomerMobile can be more painful than driving a Civic.
---
"I want a horn here, here, and here. You can never find a horn when you're mad. And they should all play `La Cucaracha'."
- Homer Simpson
Care to post the function for comparison purposes?
Dewey, what part of this looks like authorities should be involved?
I'm surprised no one mentioned (perhaps I've missed it?) Thinking In C++, by Bruce Eckel. It explains every subject in a very clear manner, providing quality examples throughout the two volumes. Not only that, you can download the book for free from http://mindview.net/
Never a -1 lame available when you need one!
And if you're new to C++, this is pretty much a must-own book.
This is the really sad part, and even sadder is that many people don't understand why it is sad.
Which one do you want!-)
I am hoping that GCC and the ANSI C++ standards committee adds a "-EvilStuff" compilation flag to force C++ developers to not include problem festering obscure features of C++ in a project.
I'm serously considering developing my next C++ project in C#/mono and then porting it to C++ so that I am forced to use a small subset of C++ to improve code quality + long term viability of the code.
A POSIX 2006 standard would help greatly especially on all of the API/STD libarry calls.
That's the best oxymoron I've seen all day! Heck, I thought Microsoft Works was a good one. But now I realize that if you want to find out what an oxymoron is, you'll have a real problem, because if you look in the dictionary, the definition is: Effective C++.
Speaking of which, did you know that naive is not in the dictionary? You: Get a dictionary, find out what this 'closure' is.
c+=c+++++c;
From g++:
foo.cc:5: non-lvalue in increment
From Sun CC:
"foo.cc", line 5: Error: Operand for operator "++" must be an lvalue.
There may also be an issue with:
c+= c++ + ++c;
Because while precedence rules apply, it may be undefined which of the 2 arguments to the + operator get evaluated first. This is very dangerous and non-portable code.
For example:
#include
using namespace std;
int main() {
double c=0;
c+=c++ + ++c;
cout << c << "\n";
}
~/ctest> g++ -O2 -Wall foo.cc ;
4
~/ctest> g++ -O2 -ffloat-store -Wall foo.cc ;
1
Does the release of the 3rd Edition mean they'll update the -Weffc++ switch for gcc?
[o]_O
thinking in java by joshua is good, But i dont thinks its as good as eff C++ is for C++.
could some mentions such a book for C#/.NET and java.
Anybody have specs on Objective C method dispatch speed vs. C++ virtual function call speed? Obj-C can't be much slower; NeXT/Apple used to have a kit for writing device drivers in Obj-C. I'd be surprised if there was more than a 50% difference.
I bought 'C++ Primer 3rd Edition' a couple of months ago.
I'm new to C++ but not new to computer languages.
I'm finding this box a dream to read, I think the previous posters paste says it all, but I highly recommend this book to somebody that wants to learn C++.
As far as i remember, this g++ option was not checking all the rules described in the 'effective C++' and 'More effective C++' books. I hope it will be available in g++ one day. By the way, there are some (paying) products that can analyze C++ source code and chez all these rules. I know Parasoft Codewizard but it's very expensive and difficult to configure to get really meaningful messages.
le souvenir d'une certaine image n'est que le regret d'un certain instant (M.Proust)
1. Convince audience of your credibility
I am a veteran at C++ programming and Java programming...
2. State your thesis.
And although you state you have no "degree of control" with Java, this is not only a loaded statement but can be misleading to those who do not have an excellent grasp on both languages.
3. Explanation
I will concur with you that the control you speak of can be very important in some applications, but not in general. Firstly, it is important to elaborate on what you mean by degree of control. There is only one good example of this as far as I see, and it is memory management. Is this a big deal for most software? Not really. The reason Java made this tradeoff is to enhance productivity--why think about memory holes when you could concentrate on problems that aren't so easy for a programming language to fix?
A followup might be, "Why not include both manual and automatic allocation?" This brings me to my next point, which is that although you have a good deal of control in C++, it does not mean the code is readable or straightforward. One of Java's largest aims is to be readable, which is VERY important for big projects and/or big teams.
4. Conclude on a clear note. Use at least one big word.
Java might not be your cup of tea, but it is exactly what the doctor ordered for a significant amount of software. I tend to think that C/C++ will be around for a while, but I frown to think that this is the case. I do not feel C/C++ is the right tool for the right job. I might be radical in saying this, but imagine a compiled language with Python syntax and a nice standard API like Java provides. Sure, for drivers we can't have our automatic memory allocation and nifty tricks like mirroring, but we sure can have a good syntax and a dependable standard library with a useful, orthogonal API.
5. Don't forget the big word.
I thought orthogonal might count...uhm... whatever, just google it.
6. ???
7. Profit! err... Karma!
seriously this book isn't worth anything and karma is already bad.
OK, design patterns, in philosophy, can do a lot of good. However, in practice, this is not always so. The golden rules in programming/design are: write code that is easy to read and write code that is easy to debug.
The problem with programming is that people tend to get lost in their little fluffy clouds and create vast, Byzantine code architectures that one invariable gets lost in (even the code authors) and is subject to a variety of weird, intermittent bugs. The same rule for writing exposition should apply to coding as well: keep it clear and concise.
Programmers need to keep their designs rooted in some reality (easy to read, easy to fix, extend, etc...). Let's face it, the possibility space of creating new code is simply too vast, but if you impose certain limits on that, then you can start writing concise code without getting lost in the fluffy clouds, or plainly, some bizarre class design that really doesn't makes sense, or has just an incredible amount of classes. Remember the GoF's comments on granularity.
Design patterns are meant to help with that, but people can abuse/misuse those as with anything else. It takes real wisdom (i.e. experience), not just book smarts, in order to use and create your own design patterns without muddying the code.
Anyways, that's my two bits,
-Chris O
While I agree that a good book (or three) on algorithms is necessary, this book does not qualify, at least IMO. I would recommend Introduction to Algorithms by Cormen, Leiserson, Rivest and Stein as one of many superior alternatives. It has a few problems as well (mostly excessive formality) but at least it has the information you need. Of course the old standby in this genre is to get all three volumes of Knuth, plus the "fasicles" of volume four that are coming out (supplemented as needed in areas he hasn't covered yet). If you can find a copy of Algorithms + Data Structures = Programs by Niklaus Wirth, it's a very good book as well (though I'm pretty sure it's been out of print for quite a while -- but getting your favorite used book store to search for ISBN 0-12-022418-9 may be worthwhile). As you might expect, this uses Pascal for its examples, but for this kind of book, the specific language used doesn't matter all that much.
If you want more detail about these books (such as why Sedgewick's is utterly worthless) see: http://tinyurl.com/d68kl.
Hmm...oddly enough, I don't have this book, and manage to get by fairly well -- IMO, if you want a book on software engineering, something by Grady Booch or Bertrand Meyer would be a better bet. Somewhere in here there should also be a mention of Structure and Interpretation of Computer Programs -- in fact, it might be the most important and useful of all -- even though it uses Scheme rather than C++.
--
The universe is a figment of its own imagination.
The universe is a figment of its own imagination.
I haven't read the STL book mentioned in the parent, but I'd reccommend using Meyers' Effective STL as a compliment. Just like Effective C++ I think it does an excellent job of clearly explaining the "why's" of its subject, leaving the "what's" for a reference book.
I've found Stroustrup's and Meyers' works invaluable at work. I was brought up on C++ during college, but my work was left me dealing with a lot more old C code than I expected. Their explanations of "these are the ugly C workarounds, now this is how C++ can do them cleanly" have really helped me understand what sorts of idioms and practices are being attempted in the old C code.
- spiff
That's like saying get a lobotomy, it'll make you more effective.
Slashdot requires you to wait 2 minutes between each successful posting of a comment to allow everyone a fair chance at posting a comment.
It's been 15 minutes since you last successfully posted a comment
Go Slashdot coders! Your skillz rulz!
doing an objc call lookup requires calling a function to search through a table to find the function address. That's easily hundreds to thousands of instructions executed. You can, however, store the function address locally, so later calls would be even faster than C++.
Do you even lift?
These aren't the 'roids you're looking for.
I read this book 6 or 7 years ago, and so many of its concepts have become fundamental to the way I design software that I was shocked when I re-read it a few months back to discover how many of what I considered "my" design and coding techniques came straight out of this book!
There are some things that are very C++ specific, and some things that are probably obsolete since this was written in 1996 (redundant include guards come to mind), but there are more than enough gold nuggets in this book to make it worth a skim even if you never use C++.
Patrick Doyle
I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
The function pointer array ("vtable") approach little space in the instruction cache, but many modern processors must incur expensive pipeline stalls to execute those instructions. Note that C++ doesn't have to be implemented this way, and test-and-branch can be much faster when only a few overrides of a method are in common use.