Programming Principles and Practice Using C++

  • ISBN13:


  • ISBN10:


  • Edition: 1st
  • Format: Paperback
  • Copyright: 12/15/2008
  • Publisher: Addison-Wesley Professional
  • View Upgraded Edition
  • Purchase Benefits
  • Free Shipping On Orders Over $59!
    Your order must be $59 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • Get Rewarded for Ordering Your Textbooks! Enroll Now
  • We Buy This Book Back!
    In-Store Credit: $2.94
    Check/Direct Deposit: $2.80
List Price: $74.99 Save up to $11.25
  • Buy New
    Add to Cart Free Shipping


Supplemental Materials

What is included with this book?

  • The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.


The inventor of C++ gives perhaps the most important introduction to programming ever written.

Author Biography

Bjarne Stroustup is the College of Engineering Chair in Computer Science Professor at Texas A&M University.

Table of Contents

Prefacep. xxiii
Notes to the Readerp. 1
The structure of this bookp. 2
A philosophy of teaching and learningp. 6
Programming and computer sciencep. 12
Creativity and problem solvingp. 12
Request for feedbackp. 12
Referencesp. 13
Biographiesp. 14
Computers, People, and Programmingp. 17
Introductionp. 18
Softwarep. 19
Peoplep. 21
Computer sciencep. 24
Computers are everywherep. 25
Ideals for programmersp. 34
The Basicsp. 41
Hello,World!p. 43
Programsp. 44
The classic first programp. 45
Compilationp. 47
Linkingp. 51
Programming environmentsp. 52
Objects, Types, and Valuesp. 59
Inputp. 60
Variablesp. 62
Input and typep. 64
Operations and operatorsp. 66
Assignment and initializationp. 69
Composite assignment operatorsp. 73
Namesp. 74
Types and objectsp. 77
Type safetyp. 78
Computationp. 89
Computationp. 90
Objectives and toolsp. 92
Expressionsp. 94
Statementsp. 99
Functionsp. 112
Vectorp. 116
Language featuresp. 123
Errorsp. 131
Introductionp. 132
Sources of errorsp. 134
Compile-time errorsp. 134
Link-time errorsp. 137
Run-time errorsp. 138
Exceptionsp. 144
Logic errorsp. 152
Estimationp. 155
Debuggingp. 156
Pre- and post-conditionsp. 161
Testingp. 164
Writing a Programp. 171
A problemp. 172
Thinking about the problemp. 173
Back to the calculator!p. 176
Grammarsp. 186
Turning a grammar into codep. 193
Trying the first versionp. 201
Trying the second versionp. 206
Token streamsp. 207
Program structurep. 213
Completing a Programp. 219
Introductionp. 220
Input and outputp. 220
Error handlingp. 222
Negative numbersp. 227
Remainderp. 228
Cleaning up the codep. 231
Recovering from errorsp. 238
Table of Contents provided by Publisher. All Rights Reserved.


" Damn the torpedoes! Full speed ahead." Admiral Farragut Programming is the art of expressing solutions to problems so that a computer can execute those solutions. Much of the effort in programming is spent finding and refining solutions. Often, a problem is only fully understood through the process of programming a solution for it. This book is for someone who has never programmed before, but is willing to work hard to learn. It helps you acquire the principles and practical skills of programming using the C++ programming language. My aim is for you to gain sufficient knowledge and experience to perform simple useful programming tasks using the best up-to-date techniques. How long will that take? As part of a first-year university course, you can work through this book in a semester (assuming that you have a workload of four courses of average difficulty). If you work by yourself, don't expect to spend less time than that (maybe 15 hours a week for 14 weeks). Three months may seem a long time, but there's a lot to learn and you'll be writing your first simple programs after about an hour. Also, all learning is gradual: each chapter introduces new useful concepts and illustrates them with examples inspired by real-world uses. Your ability to express ideas in code getting a computer to do what you want it to do gradually and steadily increases as you go along. I never say "learn a month's worth of theory and then see if you can use it." Why would you want to program? Our civilization runs on software. Without understanding software you are reduced to believing in "magic" and will be locked out of many of the most interesting, profitable, and socially useful technical fields of work. When I talk about programming, I think of the whole spectrum of computer programs from personal computer applications with GUIs (Graphical User Interfaces), through engineering calculations and embedded system control applications (such as digital cameras, cars, and cell phones), to text manipulation applications as found in many humanities and business applications. Like mathematics, programming when done well is a valuable intellectual exercise that sharpens our ability to think. However, thanks to feedback from the computer, programming is more concrete than most forms of math, and therefore accessible to more people. It is a way to reach out and change the world hopefully for the better. Finally, programming can be great fun. Why C++? You can't learn to program without a programming language and C++ directly supports the key concepts and techniques used in real-world software. C++ is one of the most widely used programming languages, found in an unsurpassed range of application areas. You find C++ applications everywhere from the bottom of the oceans to the surface of Mars. C++ is precisely and comprehensively defined by a non-proprietary international standard. Quality and/or free implementations are available on every kind of computer. Most of the programming concepts that you will learn using C++ can be used directly in other languages, such as C, C#, Fortran, and Java. Finally, I simply like C++ as a language for writing elegant and efficient code. This is not the easiest book on beginning programming; it is not meant to be. I just aim for it to be the easiest book from which you can learn the basics of real-world programming. That's quite an ambitious goal because much modern software relies on techniques considered advanced just a few years ago. My fundamental assumption is that you want to write programs for the use of others, and to do so responsibly providing a decent level of system quality. That is, I assume that you want to achieve a level of professionalism. Consequently, I chose the topics for this book to cover what is needed to get started with real-world programming, not just what is easy to teach and learn. If you need a technique to get basic work done right, I'll describe it, demonstrate concepts and language facilities needed to support the technique, provide exercises for it, and expect you to work on those exercises. If you just want to understand toy programs, you can get along with far less than I present. On the other hand, I won't waste your time with material of marginal practical importance. If an idea is explained here, it's because you'll almost certainly need it. If your desire is to use the work of others without understanding how things are done and without adding significantly to the code yourself, this book is not for you. If so, please consider if you would be better served by another book and another language. If that is approximately your view of programming, please also consider from where you got that view and whether it in fact is adequate for your needs. People often underestimate the complexity of programming as well as its value. I would hate for you to acquire a dislike for programming because of a mismatch between what you needed and the part of the software reality I describe. There are many parts of the "Information Technology" world that do not require knowledge of programming. This book is aimed to serve those who do want to write nontrivial programs. Because of its structure and practical aims, this book can also be used as a second book on programming for someone who already knows a bit of C++ or for someone who programs in another language and wants to learn C++. If you fit into one of those categories, I refrain from guessing how long it will take you to read this book, but I do encourage you to do many of our exercises. This will help you to counteract the common problem of writing programs in older, familiar, styles rather than adopting newer techniques where these are more appropriate. If you have learned C++ in one of the more traditional ways, you'll find something surprising and useful before you reach Chapter 7. Unless your name is Stroustrup, what I discuss here is not "your father's C++." Programming is learned by writing programs. In this, programming is similar to other endeavors with a practical component. You cannot learn to swim, to play a musical instrument, or to drive a car just from reading a book you must practice. Nor can you learn to program without reading and writing lots of code. This book focuses on code examples closely tied to explanatory text and diagrams. You need those to understand the ideals, concepts, and principles of programming and to master the language constructs used to express them. That's essential, but by itself, it will not give you the practical skills of programming. For that, you need to do the exercises and get used to the tools for writing, compiling, and running programs. You need to make your own mistakes, and learn to correct them. There is no substitute for writing code. Besides, that's where the fun is! On the other hand, there is more to programming much more than following a few rules and reading the manual. This book is emphatically not focused on "the syntax of C++." Understanding the fundamental ideals, principles, and techniques is essence of a good programmer. Only well-designed code has a chance of becoming part of a correct, reliable, and maintainable system. Also, "the fundamentals" are what lasts: they will still be essential after today's languages and tools have evolved or been replaced. What about computer science, software engineering, information technology, etc.? Is that all programming? Of course not! Programming is one of the fundamental topics that underlie everything in computer-related fields and has a natural place in a balanced course of computer science. I provide brief introductions to key concepts and t

Rewards Program

Write a Review