Customer Service 1-800-221-5528

Murach’s C++ Programming

by by Mary Delamater and Joel Murach
19 chapters, 774 pages, 328 illustrations
Published September 2018
ISBN 978-1-943872-27-5
List price: $59.50

Most texts teach C++ the way it was taught when the language came out 30+ years ago. They start off by presenting low-level techniques for working with memory…an approach that’s frustrating and error-prone for today’s students.

But the language itself has changed and provides higher-level coding techniques today. Plus, today’s IDEs help students with debugging and save them from the trivial syntax errors that can keep them from making steady progress.

So this book takes advantage of modern C++ to help you teach your students more quickly, easily, and effectively than ever…much more satisfying for instructors and students alike. But don’t worry: Once your students have a solid set of coding skills, it covers older techniques, so they’ll also be able to maintain legacy code and work with embedded systems.

Buy this book

You are currently on the Murach site for instructors. To buy this book, please visit our retail site.


Never have I found such a helpful book to learn to program. The format of the book was refreshing.... The examples and exercises are not the trivial examples that I have found in many books; they are examples taken from the real world of business programming. I wish I had a book like this when I was in school. It helps to reduce the learning curve required to learn a new programming language."

  • About this Book
  • Table of Contents
  • Courseware
  • FAQs
  • Corrections

Book description

How this book helps you teach C++

To make this book as effective as possible for you, the content is divided into 4 sections.

Section 1: Get your students off to a great start

  • Section 1 presents a practical subset of modern C++ that gets your students off to a great start. In fact, by the end of chapter 2, they’ll have developed their first C++ programs…programs that get input, process it, and display output…which is so much more motivating (and fun!) than writing a few lines of “Hello World” code that don’t have any practical application. This section is especially designed for beginners, but you can adapt the pace if your students have already taken an introductory programming course.
  • By the end of the 8 chapters in this section, your students will be able to code, test, and debug C++ programs using decision statements, loops, I/O streams and files, various data types, vectors, and custom functions. In short, they’ll have a solid set of the C++ skills they need on the job every day.
  • Although you can teach C++ using a text editor and a standalone compiler, this section shows how to use an IDE to work efficiently and effectively. We’ve found that having students take advantage of tools like syntax checkers and debuggers allows them to absorb the key concepts more easily and helps them get more practice in doing significant coding.

Section 2: More everyday skills as they’re needed

  • Section 2 builds on the subset to present additional C++ skills that programmers use every day. These include working with structures, enumerations, Standard Template Library (STL) containers and algorithms, built-in arrays, C strings, and exceptions.
  • You can teach the 5 chapters in this section in any order you like, and you can go as deep into any chapter as you want. The only exception to that is chapters 10 and 11; chapter 10 (on STL containers and iterators) should be taught before chapter 11 (STL algorithms). Otherwise, though, you have a lot of freedom here to customize your course.

Section 3: Object-oriented programming

  • Section 3 presents 3 chapters on object-oriented programming, complementing the procedural skills that are taught in sections 1 and 2. So when your students complete this section, they’ll be able to develop programs that combine the best procedural practices with the best object-oriented practices. 
  • These essential OOP concepts are the same in all modern-day programming languages, so once your students master them…which is easier to do using our approach…they’ll be able to apply them in any other language they use.

Section 4: Skills for legacy and generic programming

  • Section 4 lets you teach your students the classic C++ skills they need to handle legacy code or embedded systems. So here, they’ll learn about working with memory and pointers.
  • This section also shows how to use templates that allow a class to support multiple data types for generic programming.
  • Finally, this section shows how to develop custom containers and algorithms that work like the containers and algorithms of the STL presented in section 2.
  • Some of this material may go beyond the scope of your course, but your students will have it for learning and reference when they’re ready to tackle these subjects for their own work. 

What courses this book can be used for

An introductory computer science course

  • This book is designed for an introductory course in the computer science curriculum where C++ is the language used to teach programming and OOP principles. Once your students learn the essentials of C++ programming, they’ll be well prepared to learn a second language like Java. They’ll also be ready to use their C++ skills to go on to courses in artificial intelligence, big data, GUI development, gaming, and the like.

A second language course

  • This book will also work for a C++ course that’s offered after students have had an introductory course. It’s designed so you can move more quickly through the chapters in that case, skimming over familiar material and concentrating on the C++ specifics or on concepts that your students are struggling with. In fact, if your students have used a book from another publisher for their first language course, our book will help you clarify any concepts they’re confused about, as you teach C++.

Why your students will learn faster and better with our book

We’re familiar with the competing C++ books, and we’ve specifically designed this book to help your students learn faster and better than they can with any of them. Here are a few of the ways it does that:

  • There are two ways to simplify material: Avoid all complications (which is what too many books do) or present the material in the right order, at the right pace.
    We don’t think the no-complications approach gives students a true view of what programming is all about. So we present each piece slowly and methodically in section 1, building up skills and confidence, and then pick up the pace once the foundation is in place.
  • All the material is in our distinctive paired-pages format, where each topic is presented in a two-page spread: the examples and reference material are on the righthand page with additional explanation and perspective on the left.
    In today’s fast-paced world full of eager students who want to read less, do more, and pick up information on demand, it’s the ideal format. Students love it!
  • Besides fitting students’ learning style, the paired-pages format also helps your students do their assignments and prepare for tests by making it easy for them to review what they’ve learned and to refresh their memories on how to apply their new skills.
  • This book presents dozens of complete programs. In each chapter, the programs start simply to illustrate the new concepts and skills, but then show the new skills in the context of real-world programming.
    We have long felt that these programs are essential to effective learning, and no other publisher does this the way we do. Yes, other books present complete programs too, but when the programs are trivial, they limit what the students can be expected to learn.

What software your students need

Because today’s programmers typically use IDEs to save time and errors, that’s how we present C++ coding in this book.

The two IDEs we specifically cover are (1) Visual Studio with its Microsoft Visual C++ (MSVC) compiler for Windows and (2) Xcode with the open-source Clang compiler for macOS. The appendixes show how to install the IDEs, and chapter 1 gives a quick tutorial in using them.

However, you can use any IDE you want; the principles will be the same, though the installation and user details will differ. Or, if you don’t want to use an IDE, you can use a text editor and a command line.

What people say about this book

“Currently I am taking an object-oriented C++ course at a local community college, and this book helps tremendously because it is skilled-based, the most important selling point for beginners.
     “I like how the topics are introduced systematically with explanations on the left and codes on the right. The format helps me learn faster and easier as I don't have to flip back and forth. In addition, it covers topics that a normal object-oriented course would cover in a semester's time which complements great with students. Answers are also provided for reference in case students have difficulties completing the exercises.
     “Overall this is an excellent self-starter and supplementary material for college classes. Highly recommended.”
 - Posted at an online bookseller

“As a long-time trainer and developer in other programming languages (Visual Basic, C#, JavaScript, among others), I had never really had the opportunity to work in C++. I thought of C++ as being an ‘unnecessarily’ complex language whose abilities wouldn’t help me with the type of applications I needed to create.
     “Murach has created a C++ book that eased my concerns. They started with app creation that I could do easily. As the material progressed, it became clear what was unique in C++ and how C++ followed suit with other object-oriented programs that were familiar to me.
     “I enthusiastically endorse this book for the high-quality learning material it is.”
 - Don Sheehan, Veteran Technical Trainer

“As a beginner in programming, I spent many frustrated months trying to learn C++ programming using several books, including both of Bjarne Stroustrup's books. None of them were clear and did not help me to reach the level I wanted to achieve. I bought your book, Murach's C++ Programming, and within days I was able to understand all the things I previously could not.”
 - Thomas B. Wills

“I needed a crash course in C++ for an advanced class I'm taking, and having already read Murach’s C# and SQL Server books, I picked this one up. I like the Murach books' format because every even-numbered page has in-depth explanations and every odd-numbered page has code examples and summary, so if you're in a rush or just want to brush up on a topic you can skim through the odd-numbered pages.”
 - Posted at an online bookseller

“Murach's book did an excellent job explaining today’s C++, using simple yet meaningful code examples. Just typing and compiling the source code helped a lot to understand key concepts.”
 - Posted at an online bookseller

Murach's C++ Programming is a great book for those starting out with C++. It's also good for those who haven't worked with C++ in almost 20 years! I particularly like that the book covers using both Visual Studio and Xcode. Knowing how to effectively use tools to debug is important. Good book!”
 - Jeanne Boyarsky,

“Each topic is a lesson unto itself, which makes this a book with a very good pace but not at the expense of effective learning. It's a great introduction into C++ development.”
 - Posted at an online bookseller

View the table of contents for this book in a PDF: Table of Contents (PDF)

Click on any chapter title to display or hide its content.

Section 1 Essential skills for modern C++

Chapter 1 An introduction to C++ programming

An overview of programming and C++

Four general-purpose programming languages

A brief history of C++

A quick look at C++ development

The user interface for a console application

The source code for a console application

How source code compiles to an executable file

Four popular IDEs and compilers

How to use Visual Studio for Windows development

How to open a project and work with source code

How to compile and run a projects

How to use code completion and error detection

How to create a new project

How to use Xcode for macOS development

How to open a project and work with source code

How to compile and run a project;

How to use code completion and error detection;

How to create a new project

Chapter 2 How to write your first programs

Basic coding skills

How to code statements

How to code comments

How to code a main() function

How to create identifiers

How to work with numeric variables

How to define and initialize variables

How to code assignment statements

How to code arithmetic expressions

How to use the console for input and output

How to include header files

How to write output to the console

How to read input from the console

The Gallons to Liters program

How to work with the standard library

How to call a function

How to work with the std namespace

The Circle Calculator program

How to generate random numbers

How to work with char and string variables

How to assign values to char and string variables

How to work with special characters

How to read strings and chars from the console

How to fix a common problem with reading strings

The Guest Book program

How to test and debug a program

How to test a program

How to debug a program

Chapter 3 How to make decisions

How to get started with if statements

How to use the relational operators

How to code an if statement

How to work with braces

The Invoice 1.0 program

More skills for coding if statements

How to use the logical operators

If statements that use the logical operators

How to code nested if statements

The Invoice 2.0 program

Other ways to make decisions

How to use the conditional operator

How to code switch statements

More examples of switch statements

A switch statement for the Invoice 2.0 program

Chapter 4 How to code loops

More skills for coding arithmetic expressions

How to use arithmetic unary operators

How to use the compound assignment operators

How to work with the order of precedence

How to code while and do-while loops

How to code while loops

More examples of while loops

How to code do-while loops

The Test Scores program

How to code for loops and nested loops

How to code for loops

The Future Value program

How to code nested loops

How to code break and continue statements

How to code break statements

How to code continue statements

The Guess the Number program

Chapter 5 How to work with I/O streams and files

How to work with input streams

An introduction to streams and buffers

How unexpected input can cause problems

How to discard data from an input stream

How to detect data input errors

How to handle data input errors

How to work with output streams

An introduction to stream manipulators

How to specify the width of a column

How to right or left justify columns

How to format floating-point numbers

The Invoice 3.0 program

How to work with file streams

How to read and write a file

How to append data to a file

How to use the fstream object to work with files

How to check for errors when working with files

How to read and write delimited data

The Temperature Manager program

How to work with string streams

How to use a string stream to handle unexpected data

The Temperature Analyzer program

Chapter 6 How to work with data types, strings, and vectors

Basic skills for working with data types

The fundamental data types

How to define and initialize variables

How to define and initialize constants

The Light Years Calculator program

More skills for working with data types

How to work with type conversion

How to work with data type sizes and limits

How to fix problems with floating-point data

How to work with vectors

How to create a vector and refer to its elements

How to initialize and loop through a vector

How to use member functions of a vector

The Test Scores program

The Temperature Manager program

How to work with strings

How to create and loop through a string

How to use basic member functions of a string

How to search a string

How to work with substrings

How to modify a string

How to check characters within a string

The Create Account program

The Word Jumble program

Chapter 7 How to code functions

How to start coding your own functions

How to define and call a function

The Miles Per Gallon program

How to declare a function

When and how to use local and global variables

How to plan the functions of a program

How to use a hierarchy chart

The Convert Temperatures program

More skills for coding functions

How to use default values for arguments

How to overload a function

How to use reference variables as parameters

How to use reference parameters to improve efficiency

The Temperature Manager program

How to work with header files and namespaces

How to create, implement, and use header files

How to define namespaces

A header for getting input from the console

The Future Value program

Chapter 8 How to test, debug, and deploy a program

Basic skills for testing and debugging

Typical test phases

The three types of errors

Common C++ errors

How to plan the test runs

A simple way to trace code execution

How to use Visual Studio to debug a program

How to set and remove breakpoints

How to step through code

How to inspect variables

How to inspect the stack trace

How to use Xcode to debug a program

How to set and remove breakpoints

How to step through code

How to inspect variables

How to inspect the stack trace

How to deploy and run a program

How to deploy a program

How to run a deployed program

Section 2 More skills as you need them

Chapter 9 How to work with structures and enumerations

Basic skills for working with structures

How to get started with structures

How to initialize a structure

The Movie List 1.0 program

More skills for working with structures

How to nest structures

How to use structures with functions

How to compare structures for equality

How to work with member functions

How to work with member operators

The Movie List 2.0 program

How to work with enumerations

Basic skills for working with scoped enumerations

More skills for working with scoped enumerations

How to work with unscoped enumerations

The Monthly Bonus Calculator program

Chapter 10 How to work with STL containers and iterators

An introduction to STL containers and iterators

A summary of STL containers

A summary of STL iterators

Basic skills for working with iterators

Member functions shared by the STL containers

How to iterate the data in a container

More skills for working with vectors

Member functions shared by the sequence containers

Member functions of a vector

How to set capacity to improve efficiency

The Movie Rankings 1.0 program

How to work with arrays

Basic skills for working with arrays

How to pass an array to a function

How to work with lists

An introduction to lists and forward lists

Member functions of a list

The Movie Rankings 2.0 program

How to work with queues and stacks

How to work with queues

How to work with stacks

How to work with sets

Member functions of associative containers

Code examples that work with sets

How to work with maps

Member functions and operators of a map

How to insert key/value pairs and work with values by key

The Word Counter program

How to work with nested containers

How to work with a vector of vectors

How to work with a map of vectors

Chapter 11 How to work with STL algorithms

An introduction to STL algorithms

The relationship between containers, iterators, and algorithms

How to call an algorithm

How to pass a function as an argument

Basic skills for working with algorithms

How to use the non-modifying algorithms

How to use the modifying algorithms

How to use the min and max algorithms

How to use the numeric algorithms

How to use the sort and binary search algorithms

The Number Cruncher program

More skills for working with algorithms

How to use algorithms with intervals of key/value pairs

How to use algorithms with nested containers

More skills for passing functions to algorithms

How to work with function templates

How to work with function objects

How to work with lambda expressions

The Uptime Percentage program

Chapter 12 How to work with built-in arrays and C strings

Basic skills for built-in arrays

How to create an array and access its elements

How to initialize an array

How to loop through an array

How to pass an array to a function

How to compare and copy arrays

The Test Scores program

How to work with C strings

An introduction to C strings

How to use C strings with input streams

Some utility functions for working with C strings

How to loop through a C string

The Create Account program

Advanced skills for built-in arrays

How to search an array

How to sort an array

How to use STL algorithms with built-in arrays

How to work with a two-dimensional array

How to pass a two-dimensional array to a function

The Top Five program

Chapter 13 How to work with exceptions

How to get started with exceptions

A function that doesn't use exceptins

How to throw an exception

How to catch an exception

A program that catches exceptions

A program that prevents exceptions from being thrown

More skills for working with exceptions

How to catch multiple exceptions

How to rethrow an exception

The Temperature Manager program

How to work with custom exceptions

How exception handling works

Section 3 Object-oriented programming

Chapter 14 How to define classes

An introduction to object-oriented programming

A Movie structure that doesn't provide encapsulation

A Movie class that provides encapsulation

How to define private data members

How to define getter and setter functions

The Movie List 1.0 program

More skills for coding member functions

How to work with private member functions

How to convert between numbers and strings

How to define constructors

How to define destructors

How to store a class in header and source files

The header and source files for a Movie class

When and how to use inline functions

The Move List 2.0 program

How to work with UML diagrams

An introduction to UML diagrams

UML diagrams with data types

A Product class that implements a UML diagram

The Product Viewer program

How to work with object composition

A Die class

A Dice class

The Dice Roller program

The Pig Dice game

The console

The code

Chapter 15 How to work with inheritance

How to get started with inheritance

How inheritance works

How to define a superclass

How to define a subclass

How to define another subclass

How polymorphism works

The Product Viewer program

More skills for working with inheritance

How to define an abstract class

How to control overriding

How to work with multiple inheritance

How multiple inheritance works

The DayReader superclass

The DayWriter superclass

The DayIO subclass

When to use inheritance

How to use inheritance with custom exceptions

Guidelines for using inheritance

Chapter 16 More skills for object-oriented programming

How to work with static members

How to code static data members and functions

How to access static data members and functions

The Console class

Code that uses the Console class

How to work with a friend function

The FuelTank class

A friend function that works with two classes

How to overload operators

How to overload arithmetic binary operators

How to overload arithmetic unary operators

How to overload relational operators

How to overload the insertion and extraction operators

Section 4 Skills for legacy and generic programming

Chapter 17 How to work with memory and pointers

An introduction to pointers and memory

How physical memory works

How to define and use pointers

More skills for defining and using pointers

How pointer variables compare to reference variables

How to use pointers with functions

How and when to pass pointers to functions

How to use the this pointer in a member function

The Step Counter 1.0 program

The Step Counter 2.0 program

How to use pointers to work with dynamic memory

An overview of the types of storage

How to allocate and deallocate free store memory

How to avoid memory leaks and memory corruption

How to use RAII (Resource Acquisition Is Instantiation)

How to implement the Rule of Three with RAII

How to implement the Rule of Five with RAII

How to work with smart pointers

The Sensor Analysis program

More skills for working with pointers

How to compare pointers

How to use pointer arithmetic

How to work with void pointers

How to use pointers with inheritance

How to understand complex compound types

Chapter 18 How to work with templates

How to work with function templates

An overloaded function

A function template

How to code a function template with one type parameter

How to code a function template with multiple type parameters

How to work with class templates

How to code a simple class template

How to code a more complex class template

How to code a function template that works with a class template

The Sensor Analysis program

Chapter 19 How to code custom containers, iterators and algorithms

How to code a custom container

How to work with member types

The MyVector class declaration

The constructor and destructor definitions

The assignment operator definitions

The member function definitions

The Task Manager 1.0 program

How to code a custom iterator

How to work with iterator traits

The Link structure

The MyIterator class

The MyList class declaration

The destructor definition

The member function definitions

The Task Manager 2.0 program

How to code a custom algorithm

The find_midpoint() algorithm

The Number Cruncher program


Appendix A How to set up Windows for this book

How to install the Visual Studio IDE

How to install the source code for this book

Appendix B How to set up macOS for this book

How to install the Xcode IDE

How to install the source code for this book

How the source code makes it easier for Xcode projects to store data in files

How our courseware differs from others

In contrast to other college publishers, we don’t fill dozens of pages in our books with end-of-chapter activities that may never be used.

Instead, we provide everything you need for an effective course in the instructor’s materials, which you can request from our instructor’s website. Then, you decide which of these materials you want to use.

What follows is a summary of the instructor’s materials for this book; for a detailed description in PDF format, please read the Instructor’s Summary. As we see it, these materials provide everything that you need for running a great course...without the counter-productive busywork of other texts.

End-of-chapter (EOC) exercises

  • In the EOC activities for all of our books, you’ll find carefully designed exercises that let your students (1) practice what they’ve just learned and (2) help them apply what they’ve learned in new ways.
  • What’s different about these? Other books may have a ton of exercises, but each covers maybe one or two skills at a time. So if you assign one, or even a dozen, students still don’t get to practice all the other skills, and they never see how the skills interact.

    But each of the exercises in our C++ book has your students practice interrelated skills all at the same time. So when they finish a chapter’s exercises, they will have used all of the important new skills in that chapter, just as they would in the real world.
  • Our exercises start from partial programs, so your students can focus on new skills and not waste time on repetitive code that they’d never code from scratch in a work environment.
  • Students can download the solutions to the EOC exercises (as well as the exercise starts) for free from our retail website.

    We started providing the solutions for the professionals who use our books for self-training. But we’ve found that they keep students from giving up when they get stuck on a problem at midnight, and that the model code also helps them refine their future work.

    And don’t worry! We provide additional projects and case studies that you can use for testing, where the solutions are available only to instructors (see below).
  • Taken together, this unique system allows students to practice more…and learn more!…in much less time.


  • Today, most textbooks include objectives, but they are often so poorly conceived that they are ignored by both students and instructors. In contrast, we provide objectives that describe the skills that the students should master, and mastery can be measured by the test banks, projects, and case studies that we provide. As a result, our objectives actually do facilitate learning.

Test banks

  • To test comprehension, we provide test banks in multiple formats.
  • Each test bank provides questions that are designed to test the skills described by the objectives for that chapter, and each test question is designed to test the skill described by one objective. This keeps the promise to the students that they will only be expected to have the skills that are described by the objectives.
  • In the test banks, we use only multiple-choice test questions because they’re easy to score and (more important) have the highest validity. In other words, the students with the best knowledge and skills will get the best scores. In contrast, matching and true/false questions have low validity, so we don’t use them.


  • The best way to develop programming skills is to write, test, and debug programs from scratch. To that end, we provide a set of projects for each chapter. These projects can be used for both practice and tests.
  • To make the projects as useful as possible, ours provide a range of difficulty levels. That way, you can assign projects at levels that are appropriate for the students in your class.
  • Because your students should be able to finish some of these projects in an hour or less, you can also use these projects as tests that can be done in a computer lab. That is the only sure way to test whether your students have the skills described by the objectives.

Case studies

  • We also provide case studies for this book that can be used as midterm or final projects. These case studies are designed so they shouldn’t take more than 10 or 12 hours. But they are also designed so you can easily modify them so they’re more or less difficult.

PowerPoint slides

  • In our books, the figures present all of the critical information including screen shots, diagrams, tables, examples, and programs. Then, we build our PowerPoint slides from the figures, which means that our slides let you review the critical material that’s presented in the book. This makes it easy to answer any questions that your students raise or review any skills that your students are having trouble with.
  • In addition, the slides for each chapter start with the objectives for the chapter. They also end with slides that summarize the projects and case studies so it’s easy to review and discuss them.
  • The slides for this book meet the current accessibility standards.

    However, the eBook edition of this text is also fully accessible, and it’s the best way to fulfill the accessibility needs of your students. In fact, sometimes the advice on creating accessible slides is to create a PDF to explain the slide content – which, in essence, is what the eBook does!

A turnkey package

    • Our instructor’s materials also include everything else that you need for the course, like all the starting files and solutions for the projects and case studies. So what you end up with is a turnkey package for a powerful C++ course.

On this page, we’ll be posting answers to the questions that come up most often about our C++ book. So if you have any questions that you haven’t found answered here at our site, please email us. Thanks!

To view the corrections for this book in a PDF, just click on this link: View the corrections

Then, if you find any other errors, please email us so we can correct them in the next printing of the book. Thank you!

Murach college books and courseware since 1974