C++ Black Book

C++ Black Book

5.0 1
by Steve Holzner

View All Available Formats & Editions

This book was written to the most current ANSI/ISO specifications for C++. It presents file handling, virtual functions, exceptions, debugging, plus the standard template library. It also covers data handling including sorting, searching and encryption, hashing, and parsing. It provides information on data structures, unions, enumerations, classes, and objects


This book was written to the most current ANSI/ISO specifications for C++. It presents file handling, virtual functions, exceptions, debugging, plus the standard template library. It also covers data handling including sorting, searching and encryption, hashing, and parsing. It provides information on data structures, unions, enumerations, classes, and objects including friend functions, copy constructors, and advanced tricks.

Editorial Reviews

Holzner, a master programmer with over 1 million books in print, manages to corral all his C++ knowledge into one all-encompassing book for beginning to advanced programmers. Using nearly 500 examples, he describes how to master ANSI/ISO C++; understand all the built-in ANSI/ISO C++ syntax; master all aspects of object-oriented programming (OOP); use virtual methods and runtime polymorphism; create abstract classes and pure virtual methods; create function and class templates; handle implicit conversions between classes; work with file and I/O stream handling; create and use I/O manipulators; master Standard Template Library (STL) containers and algorithms; create and use STL iterators; and create class-based function objects. The CD-ROM contains code examples. Annotation c. Book News, Inc., Portland, OR (booknews.com)

Product Details

Paraglyph Press, Inc.
Publication date:
Black Book (Paraglyph Press) Series
Edition description:
Product dimensions:
7.38(w) x 9.20(h) x 1.76(d)

Read an Excerpt

Chapter 1: Essential C++

Welcome to the big book of C++. If you want to get into C++ programming, this is the place. You'll find all that you need in this book. C++ programming is not like ordinary programming-it inspires passion, devotion, even obsession. Everywhere in the C++ world you look, you'll find C++ fanatics-and for good reason. C++ has long been a programmer's language, lean enough and close enough to the machine to satisfy nearly everyone's need for precision and control. It's got a strong, clean feel to it, and enough power to make a little go a long way. It's also powerful enough to become obscure very quickly when you start doing some advanced pointer work, and the result is that you'll find programmers clinging to their own ways of doing things and insisting that they're the only way to go. It's my hope that this book will help turn you into a C++ fanatic too.

There's a lot to learn and master here, and we're going to see it all. I'm going to try to lay it out in the best possible way, with plenty of examples, to make our path as smooth as possible. Bjarne Stroustrup, the creator of C++, has advised programmers to "ease yourself into the language," and that's just what we'll do.

In this book, we're going to learn all about C++ in the best way: by seeing it at work. We'll avoid the dry cataloging type of teaching, which piles up layer after layer of formal theory. Instead, we're going to see the language in its own environment, which will give us a working knowledge of just what it can do. Here, the programmer is in charge-the idea behind C++ is to give more power to the programmer, and that's what we'll be doing. We're going to see all that C++ has to offer, from object-oriented programming and memory control to templates and generic programming techniques. It's worthwhile starting with a history of the language to put things in perspective.

The History of C++

As you probably know, the C++ language itself is actually a superset of the C programming language (its first name was C with Classes). The reason the C language is called C is, simply, that it is the successor to the language called B. That language was developed by Ken Thompson in 1970, working on a DEC PDP-7, which is far less powerful than a modern PC. The original UNIX operating system ran on that machine, and that's also where B got its start. (B itself was the successor to a language called BCPL, which was written by Martin Richards.)

However, B was a little restricted. In 1972, Dennis Ritchie and Ken Thompson created the C language to augment B's power. C did not become popular immediately after its creation; in fact, it remained almost an esoteric topic for the next six years. In 1978, however-a historic year for C and C++ programmers-Brian Kernighan and Dennis Ritchie wrote a famous book for Prentice-Hall named The C Programming Language. And that simple book changed everything.

Now that word was out, there was an explosion of interest, and C was implemented on 8-bit computers under the CP/M operating system. It wasn't until the introduction of the IBM PC in 1981, however, that C really came into its own. When the PC revolution began, C was in a perfect position to take advantage of it. As the number of PCs shot upwards, so did the number of C users. C broke away from its original UNIX background and became a popular language on microcomputers.

It's worth stressing that it became popular for a very good reason: programmers liked using it. Unlike many other languages, C gave the programmer a great deal of control over the computer. With that control comes responsibility-there are many things you can do in C that will ruin your program or crash your computer. That is, you have the power to do things in C that other languages would never allow you to do. And programmers liked that; they liked fording a language that was a tool, not an obstacle. To programmers, C was much like assembly language without the drawback of having to do everything for yourself-in other words, C seemed much like the perfect combination of control and programming power.

ANSI Standardizes C

All this made for such a popular language that different companies started to bring out their own versions of C, and each one began to go in a different direction. The C revolution was in danger of splintering into many incompatible programming packages. For that reason, the American National Standards Institute (ANSI) created a special subcommittee named X3J11 to create a standard version of C. This was an extremely important development for C and C++ programmers; the language, which had been going off in all directions at the same time, became standardized and coherent once more. For that reason, ANSI C did indeed become standard C.

C++ Appears

As the popularity of C grew, so did the number of applications written in C. In time, C programs grew longer and longer, and some people began to feel that the standard programming constructions just weren't up to the task. One solution was to make the program more modular, more compartmentalized, and you could use functions to do that. However, some functions might end up needing to share data, some needed to coordinate with others, and again, you could end up with dozens of things to keep in mind (and dozens of functions in the program's global scope).

In 1983, Bjarne Stroustrup developed C++, inspired in part by other languages like Simula67. The name C++ itself, as you may know, comes from the C operator ++, which increments its argument-and so C++ is intended to be augmented C. C++ is much like C, but with a number of important extensions. In other words, all that we know about C still applies-but C++ offers us even more power. Primary among the additions C++ brings to C is the idea of an object.

An object is really just like a new kind of programming structure, except that it can hold both data and functions-both of which can be private to the object if you want them to be. As mentioned above, the driving force behind objects is modularity. Programmers found that when they were struggling with large programs, the more modular their programs the better (C++ was originally written to be used when programs got very long, over 2,500 lines). That's what C++ does; it helps us wrap up sections of our programs into discrete units, each of which serves some (easily remembered) purpose.

Although C++ was originally developed to introduce large-scale modularity to C, there axe other parts of C++ that made it attractive even if your program is short. One such aspect is its legendary flexibility; we can redesign just about all of the C operators in C++ as well as do (previously) unheard-of things with functions. For example, through function overloading, we'll be able to call the same function with parameters of different types (e.g., int, float). C++ will decide which version of the function to use based on the types of the parameters we're passing (in C, naturally, this would be an error).

What originally attracted programmers to C++ was object-oriented programming (OOP), and I remember seeing dozens of programmers in the early days being attracted to the OOP banner, whether they needed it or not. There's also another aspect of C++, more recently introduced and now made standard, that is also as highly regarded: generic programming. Generic programming, like OOP, makes code reuse easier, and in fact, that's its speciality. Generic programming lets you think in terms of algorithms, which are specific techniques for getting things done, such as a really efficient way you've found to sort numbers. Using generic programming and C++ templates, you can implement the algorithm once in your code and use it with many different types of data, even with objects...

Meet the Author

Steve Holzner is an award-winning author who has been writing about Java topics since Java first appeared. He's a former PC Magazine contributing editor, and his many books have been translated into 18 languages around the world. His books sold more than 1.5 million copies, and many of his bestsellers have been on Java. Steve graduated from MIT and got his PhD at Cornell; he's been a very popular member of the faculty at both MIT and Cornell, teaching thousands of students over the years and earning an average student evaluation over 4.9 out of 5.0. He also runs his own software company and teaches week-long classes to corporate programmers on Java around the country.

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >

C++ Black Book 5 out of 5 based on 0 ratings. 1 reviews.
Guest More than 1 year ago
If you are a programmer tranitioning from C to C++ or even from another language altogether this is an excelent way to make that transition. If you are a beginning programmer with a basic understanding of programming concepts (functions, variables, etc.) then this is also a great book for you. The author does a good job of working through each subject, explaining it in good detail and then dissecting the code to make it very readable. I was particularly impressed by the presentation of the book. Kudos to whoever did the layout because the book looks sharp and is very accessable via all the cross references that easily direct you to related sections. If you're looking for a book that will give you an advanced (not expert) level of understanding on a very broad range of C++ topics than I heartily recommend this title. If you need specific information on a subject, say STL or generic algorithms you're probably better off getting a specilized reference, although the author does cover these technologies in a fair amount of detail.