Programming: Principles and Practice Using C++ (2nd Edition)

Author: Bjarne Stroustrup
This Year Stack Overflow 1
This Month Reddit 2


by ImperialRenaissance   2019-08-24

This is a very dense book, but is undoubtedly the best for learning C++ and I would argue programming in general. Just be aware, as with learning the 'vanilla' version of any programming language, you may feel dissatisfied with still not being able to do too much, and while the book does introduce GUI programming with C++ with the Fast Light Toolkit, I would suggest learning SFML or even how to use C++ within the Unreal Engine to truly motivate you.

Remember that there is no utility in learning a programming language in of itself, only in being able to actually do something with it.

by JonKalb   2019-08-24

Modern C++ (C++11 or later) books are not nearly as plentiful as those for Classic C++, but there are a few notables.

Bjarne's college text may be what you are looking for:

Programming: Principles and Practice Using C++

It is aimed at engineers, which makes it less general, but might be good for you.

Of course his general intro is also updated to C++11.

 The C++ Programming Language

This is aimed at experienced systems programmers, so it may be a bit heavy for students, which makes the Primer (that you mentioned attractive).

C++ Primer

Be certain to get the 5th edition.

Of Scott's books only the latest is Modern.

Effective Modern C++

This is less an introduction for students than for Journeymen (Journeypeople?) programmers.

For just plain good programming style consider Ivan's book.

 Functional Programming in C++

Don't be put off by "Functional." This style of programming will make your students excellent programmers.

There are some modern books of high quality that are niche.

The ultimate guide to templates: C++ Templates

The ultimate guide to concurrency: C++ Concurrency in Action

Some library options:

Despite its name, this is mostly reference. A very good reference. The C++ Standard Library: A Tutorial and Reference (2nd Edition)

Arthur's book covers C++17, which makes it one of the most modern on this list: Mastering the C++17 STL: Make full use of the standard library components in C++17

To what extent are you teaching C++ and to what extent are you teaching programing?

Good luck and have fun!

by cfeyer   2019-07-21

I've heard good things about

Bjarne Stroustrup

Programming: Principles and Practice Using C++ (2nd Edition)

Haven't read it, but I do have Stroustrup's more advanced "The C++ Programming Language" book and can tell you he's a great author.

by [deleted]   2019-07-21

Beginning C++ Programming - From Beginner to Beyond by Frank Mitropoulos and Tim Buchalka was a great course to supplement my C++ college course. Also, if you like reading, Programming: Principles and Practice Using C++ (2nd Edition) by Bjarne Stroustrup is a good book to start on. Additionally, I'd suggest Algorithms (4th Edition) by Robert Sedgewick. Feel free to reach out to me, never hurts to have more friends in this field :)

by anonymous   2018-05-29
@Cheersandhth.-Alf, @Tyker, @NickyC - See [why does the use of new cause memory leaks]( Also, I recommend you read a beginners book on C++, such as [Stroustrup's Programming: Principles and Practice Using C++](,204,203,200_QL40_&dpSrc=detail) which very clearly states on p. 600 that not using `delete` **causes a memory leak.** You usually should not rely on OS-freeing.
by litb   2017-08-20


Introductory, no previous programming experience

Introductory, with previous programming experience

* Not to be confused with C++ Primer Plus (Stephen Prata), with a significantly less favorable review.

Best practices



Reference Style - All Levels

C++11/14 References:

  • The C++ Standard (INCITS/ISO/IEC 14882-2011) This, of course, is the final arbiter of all that is or isn't C++. Be aware, however, that it is intended purely as a reference for experienced users willing to devote considerable time and effort to its understanding. As usual, the first release was quite expensive ($300+ US), but it has now been released in electronic form for $60US.

  • The C++14 standard is available, but seemingly not in an economical form – directly from the ISO it costs 198 Swiss Francs (about $200 US). For most people, the final draft before standardization is more than adequate (and free). Many will prefer an even newer draft, documenting new features that are likely to be included in C++17.

  • Overview of the New C++ (C++11/14) (PDF only) (Scott Meyers) (updated for C++1y/C++14) These are the presentation materials (slides and some lecture notes) of a three-day training course offered by Scott Meyers, who's a highly respected author on C++. Even though the list of items is short, the quality is high.

  • The C++ Core Guidelines (C++11/14/17/…) (edited by Bjarne Stroustrup and Herb Sutter) is an evolving online document consisting of a set of guidelines for using modern C++ well. The guidelines are focused on relatively higher-level issues, such as interfaces, resource management, memory management and concurrency affecting application architecture and library design. The project was announced at CppCon'15 by Bjarne Stroustrup and others and welcomes contributions from the community. Most guidelines are supplemented with a rationale and examples as well as discussions of possible tool support. Many rules are designed specifically to be automatically checkable by static analysis tools.

  • The C++ Super-FAQ (Marshall Cline, Bjarne Stroustrup and others) is an effort by the Standard C++ Foundation to unify the C++ FAQs previously maintained individually by Marshall Cline and Bjarne Stroustrup and also incorporating new contributions. The items mostly address issues at an intermediate level and are often written with a humorous tone. Not all items might be fully up to date with the latest edition of the C++ standard yet.

  • (C++03/11/14/17/…) (initiated by Nate Kohl) is a wiki that summarizes the basic core-language features and has extensive documentation of the C++ standard library. The documentation is very precise but is easier to read than the official standard document and provides better navigation due to its wiki nature. The project documents all versions of the C++ standard and the site allows filtering the display for a specific version. The project was presented by Nate Kohl at CppCon'14.

Classics / Older

Note: Some information contained within these books may not be up-to-date or no longer considered best practice.

by anonymous   2017-08-20

As pointed in all the comments on your question, your error occurs because you wrote your code out of a main function. Each C++ program must have it.

By the way, here are good practices for free (found also in comments).

by RotsiserMho   2017-08-19
That's his reference book. It's not designed for systematic learning. It's designed as a reference, as in "cut-and-paste stuff". You want one of his other books, meant to take you from zero to literate in not just C++11 but programming in general: