- Paperback: 1224 pages
- Publisher: Sams; 5 edition (November 25, 2004)
- Language: English
- ISBN-10: 0672326973
- ISBN-13: 978-0672326974
- Product Dimensions: 7.4 x 1.5 x 9 inches
- Shipping Weight: 4.4 pounds
- Average Customer Review: 454 customer reviews
- Amazon Best Sellers Rank: #579,326 in Books (See Top 100 in Books)
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
C++ Primer Plus (5th Edition) 5th Edition
Use the Amazon App to scan ISBNs and compare prices.
There is a newer edition of this item:
The Amazon Book Review
Author interviews, book reviews, editors picks, and more. Read it now
Customers who bought this item also bought
What other items do customers buy after viewing this item?
About the Author
Stephen Prata teaches astronomy, physics, and computer science at the College of Marin in Kentfield, California. He received his B.S. from the California Institute of Technology and his Ph.D. from the University of California, Berkeley. Stephen has authored or coauthored more than a dozen books for The Waite Group. He wrote The Waite Group's New C Primer Plus, which received the Computer Press Association's 1990 Best How-to Computer Book Award, and The Waite Group's C++ Primer Plus, nominated for the Computer Press Association's Best How-to Computer Book Award in 1991.
Excerpt. © Reprinted by permission. All rights reserved.
Preface to the Fifth Edition
Learning C++ is an adventure of discovery, particularly because the language accommodates several programming paradigms, including object-oriented programming, generic programming, and the traditional procedural programming. C++ was a moving target as the language added new features, but now, with the ISO/ANSI C++ Standard, Second Edition (2003), in place, the language has stabilized. Contemporary compilers support most or all of the features mandated by the standard, and programmers have had time to get used to applying these features. The fifth edition of this book, C++ Primer Plus, reflects the ISO/ANSI standard and describes this matured version of C++.
C++ Primer Plus discusses the basic C language and presents C++ features, making this book self-contained. It presents C++ fundamentals and illustrates them with short, to-the-point programs that are easy to copy and experiment with. You'll learn about input/output (I/O), how to make programs perform repetitive tasks and make choices, the many ways to handle data, and how to use functions. You'll learn about the many features C++ has added to C, including the following:
Classes and objects
Polymorphism, virtual functions, and runtime type identification (RTTI)
Generic, or type-independent, programming, as provided by templates and the Standard Template Library (STL)
The exception mechanism for handling error conditions
Namespaces for managing names of functions, classes, and variables
The Primer Approach
C++ Primer Plus brings several virtues to the task of presenting all this material. It builds on the primer tradition begun by C Primer Plus nearly two decades ago and embraces its successful philosophy:
A primer should be an easy-to-use, friendly guide.
A primer doesn't assume that you are already familiar with all relevant programming concepts.
A primer emphasizes hands-on learning with brief, easily typed examples that develop your understanding, a concept or two at a time.
A primer clarifies concepts with illustrations.
A primer provides questions and exercises to let you test your understanding, making the book suitable for self-learning or for the classroom.
Following these principles, the book helps you understand this rich language and how to use it. For example:
It provides conceptual guidance about when to use particular features, such as using public inheritance to model what are known as is-a relationships.
It illustrates common C++ programming idioms and techniques.
It provides a variety of sidebars, including tips, cautions, things to remember, compatibility notes, and real-world notes.
The author and editors of this book do our best to keep the presentation to-the-point, simple, and fun. Our goal is that by the end of the book, you'll be able to write solid, effective programs and enjoy yourself doing so.
Sample Code Used in This Book
This book provides an abundance of sample code, most of it in the form of complete programs. Like the previous editions, this book practices generic C++ so that it is not tied to any particular kind of computer, operating system, or compiler. Thus, the examples were tested on a Windows XP system, a Macintosh OS X system, and a Linux system. Only a few programs were affected by compiler non-conformance issues. Compiler compliance with the C++ standard has improved since the previous edition of this book first appeared.
The sample code for the complete programs described in this book is available on the Sams website, at http://www.samspublishing.com. Enter this book's ISBN (without the hyphens) in the Search box and click Search. When the book's title is displayed, click the title to go to a page where you can download the code. You also can find solutions to selected programming exercises at this site.
How This Book Is Organized
This book is divided into 17 chapters and 10 appendixes, summarized here.
Chapter 1: Getting Started
Chapter 1 relates how Bjarne Stroustrup created the C++ programming language by adding object-oriented programming support to the C language. You'll learn the distinctions between procedural languages, such as C, and object-oriented languages, such as C++. You'll read about the joint ANSI/ISO work to develop a C++ standard. This chapter discusses the mechanics of creating a C++ program, outlining the approach for several current C++ compilers. Finally, it describes the conventions used in this book.
Chapter 2: Setting Out to C++
Chapter 2 guides you through the process of creating simple C++ programs. You'll learn about the role of the main() function and about some of the kinds of statements that C++ programs use. You'll use the predefined cout and cin objects for program output and input, and you'll learn about creating and using variables. Finally, you'll be introduced to functions, C++'s programming modules.
Chapter 3: Dealing with Data
C++ provides built-in types for storing two kinds of data: integers (numbers with no fractional parts) and floating-point numbers (numbers with fractional parts). To meet the diverse requirements of programmers, C++ offers several types in each category. Chapter 3 discusses those types, including creating variables and writing constants of various types. You'll also learn how C++ handles implicit and explicit conversions from one type to another.
Chapter 4: Compound Types
C++ lets you construct more elaborate types from the basic built-in types. The most advanced form is the class, discussed in Chapters 9 through 13. Chapter 4 discusses other forms, including arrays, which hold several values of a single type; structures, which hold several values of unlike types; and pointers, which identify locations in memory. You'll also learn how to create and store text strings and to handle text I/O by using C-style character arrays and the C++ string class. Finally, you'll learn some of the ways C++ handles memory allocation, including using the new and delete operators for managing memory explicitly.
Chapter 5: Loops and Relational Expressions
Programs often must perform repetitive actions, and C++ provides three looping structures for that purpose: the for loop, the while loop, and the do while loop. Such loops must know when they should terminate, and the C++ relational operators enable you to create tests to guide such loops. In Chapter 5 you learn how to create loops that read and process input character-by-character. Finally, you'll learn how to create two-dimensional arrays and how to use nested loops to process them.
Chapter 6: Branching Statements and Logical Operators
Programs can behave intelligently if they can tailor their behavior to circumstances. In Chapter 6 you'll learn how to control program flow by using the if, if else, and switch statements and the conditional operator. You'll learn how to use logical operators to help express decision-making tests. Also, you'll meet the cctype library of functions for evaluating character relations, such as testing whether a character is a digit or a nonprinting character. Finally, you'll get an introductory view of file I/O.
Chapter 7: Functions: C++'s Programming Modules
Functions are the basic building blocks of C++ programming. Chapter 7 concentrates on features that C++ functions share with C functions. In particular, you'll review the general format of a function definition and examine how function prototypes increase the reliability of programs. Also, you'll investigate how to write functions to process arrays, character strings, and structures. Next, you'll learn about recursion, which is when a function calls itself, and see how it can be used to implement a divide-and-conquer strategy. Finally, you'll meet pointers to functions, which enable you to use a function argument to tell one function to use a second function.
Chapter 8: Adventures in Functions
Chapter 8 explores the new features C++ adds to functions. You'll learn about inline functions, which can speed program execution at the cost of additional program size. You'll work with reference variables, which provide an alternative way to pass information to functions. Default arguments let a function automatically supply values for function arguments that you omit from a function call. Function overloading lets you create functions having the same name but taking different argument lists. All these features have frequent use in class design. Also, you'll learn about function templates, which allow you to specify the design of a family of related functions.
Chapter 9: Memory Models and Namespaces
Chapter 9 discusses putting together multifile programs. It examines the choices in allocating memory, looking at different methods of managing memory and at scope, linkage, and namespaces, which determine what parts of a program know about a variable.
Chapter 10: Objects and Classes
A class is a user-defined type, and an object (such as a variable) is an instance of a class. Chapter 10 introduces you to object-oriented programming and to class design. A class declaration describes the information stored in a class object and also the operations (class methods) allowed for class objects. Some parts of an object are visible to the outside world (the public portion), and some are hidden ...
Top customer reviews
There was a problem filtering reviews right now. Please try again later.
I am a competent R programmer interested in expanding my skills to something more high performance, After struggling through the classic but sparse K&R text on C, I turned to this book. It has not disappointed. I am halfway through the book and now can easily handle basic I/O, different variable types, operators, functions, arrays, pointers (well, are pointer ever easy?) and most (all?) control statements. It is a comprehensive text that thoroughly explains principles including how and why things go wrong. The end-of-the-chapter review questions include answers, and the programming exercises (also at the end of each chapter but sans solutions) are appropriate applications of principles and skills. They were challenging, but not so impossibly hard that they could not be solved. This book, and learning C in general, also provides insight into how computers work - how they are storing the information and how to access that information, for example. Lastly, the book is wryly funny, sprinkled with all sorts of jokes about the inconveniences computers and programming can cause humanity (e.g. From Chapter 10: "There is no need to subject yourself to the ridicule of your compiler.") I'm sure the book has some downsides, but I have not yet found them. The mistakes in syntax other reviewers refer to appear to have been corrected in this edition.
to write a review based on a few things I have seen.
1. The book is very well organized. It starts from absolute basics, and builds
on everything from there. This makes going from chapter to chapter very easy.
2. Some of the examples are very easy, and others are not. You do not want a
book that does everything for you. You might get stuck for hours, but in the end
you will learn something, which leads me to...
3. The downside of this book (actually I noticed that could be debatable), is
the number of typos in the examples of code. You can tell that the editors did
catch all the copy-paste mistakes as they were made quite a bit. But sometimes I
sat for hours wondering why my code wouldn't compile only to realize he made a
typo mistake. One of them I remember is when he had done a 'switch' statement,
he left out the integer expression... and being a newbie, it takes awhile to
catch. And he confuses his pointer names A LOT, naming one *pt then switching
to *pn. The up-side to this is you will be fixing people's code in the real world,
debugging, etc... so that's how I look at it. But frustrating nonetheless.
4. Sometimes it isn't quite clear how he is explaining a certain point, but
after thinking about it a bit, it starts to make sense later, usually in examples
or when he explains other ways of doing it. For the most part, the explanations
are pretty good.
Bottom-line, the standard hasn't changed too much since this edition so unless
you want to fish out top-dollar for the 6th edition that is out now, this one
will do fine; I got mine new for $10 shipped.
I actually started with Java as my first language and classes, objects, etc
didn't make too much sense until I studied them in C++ from this book... I
recommend studying C++ as a first language rather than Java like most schools
and universities do as Java is a more higher level language than C++, meaning
it has a little more abstraction level, however in theory Java is 'easier' to C++.
Just that C++ answered all my problems I had with Java.
1) Large coverage of the language in 1 book
2) Easily readable, but also can be used for a quick reference if needs be
3) Logical progression of topics.
4) Lots of code examples.
5) Exercises and questions at the end of chapter with answers in back of book
1) Errors. Lots of them. This is version 4 of the book and it is extremely obvious that this book is just barely tweaked and resold. There is no way the author is unaware of these errors. I confirmed they were also in the 3rd edition. When it is an easy topic, you can figure out what he meant if you aren't a new programmer. However, when it gets to complicated subjects, those errors can really waste a lot of time. If this were a first edition, I'd let it slide a little more. But for a 4th edition after all these years. No way. Just shows laziness/greed.
2) Detail on certain topics. Yes I know this is a "primer," but I found explanations on Cplusplus.com sometimes covered more detail than the book on basic topics.
The book is still a good book. Not great, but good. If you need to learn C++, grabbing a used copy for under $15 is a no brainer.
The book is able to explain the extremely abstract concept
of class templates. Of all the books I own that
attempt to explain class templates, this book was
the only one that was able to do so without loosing me. C++ class
templates are, in my opinion, an extremely abstract concept that requires
a very skillful author to describe it adequately and accurately.
Stephen Prata has succeeded in doing that! Thank you so much for successfully
teaching me this topic that was once very intimidating and foreign.