C++ Primer (5th Edition)

Author: Stanley B. Lippman, Josée Lajoie, Barbara E. Moo
All Comments
TopTalkedBooks posted at August 19, 2017

I don't know much about C++ certification but C++ primer is a REALLY good reference book for C++.

To my knowledge, certifications to some companies may not matter but there is definitely no downside of picking up official and recognized certificates. Imo, I wouldn't bother and spend money on "official" certification websites. A lot of people have told me in the past to work with people on open source projects. https://github.com/trending?l=c Build connections and a following.

TopTalkedBooks posted at August 19, 2017

C++ Primer by by Stanley B. Lippman, Josée Lajoie and Barbara E. Moo is most likely what you are looking for.

Edit: Note that C++ Primer Plus is not the same book and is not as commonly recommended.

TopTalkedBooks posted at August 19, 2017

>I obviously know what a pointer is, but I want to be able to get the best of me using them

c++11 (and boost before that) has heavily reduced the need for raw pointers with smart pointers, however, you have to keep in mind that C++ is a superset of C, and you'll encounter yourself using C libraries/headers (especially on *nix environments) more often than you'd probably like, so knowing pointers/references and the general mechanics behind them is crucial in my opinion.

as far as getting up to speed with c++, i'd recommend the C++ Primer 5th Edition , since it covers just about everything you'll need including c++11, but isn't too detail heavy that it will turn you away from the language.

as far as best practices are concerned, look into meyer's Effective series of books (C++, Modern C++, STL).

this stackoverflow link is in the sidebar, and is generally the go to answer when anyone asks for book recommendations.

with c++ you can develop for any environment more or less, including the three main ones (win, linux, osx), and there's good support on all the platforms. for IDEs, visual studio and qt creator are the most popular.

TopTalkedBooks posted at August 20, 2017


Introductory, no previous programming experience

  • Programming: Principles and Practice Using C++ (Bjarne Stroustrup) (updated for C++11/C++14) An introduction to programming using C++ by the creator of the language. A good read, that assumes no previous programming experience, but is not only for beginners.

Introductory, with previous programming experience

  • C++ Primer * (Stanley Lippman, Josée Lajoie, and Barbara E. Moo) (updated for C++11) Coming at 1k pages, this is a very thorough introduction into C++ that covers just about everything in the language in a very accessible format and in great detail. The fifth edition (released August 16, 2012) covers C++11. [Review]

  • A Tour of C++ (Bjarne Stroustrup) (EBOOK) The “tour” is a quick (about 180 pages and 14 chapters) tutorial overview of all of standard C++ (language and standard library, and using C++11) at a moderately high level for people who already know C++ or at least are experienced programmers. This book is an extended version of the material that constitutes Chapters 2-5 of The C++ Programming Language, 4th edition.

  • Accelerated C++ (Andrew Koenig and Barbara Moo) This basically covers the same ground as the C++ Primer, but does so on a fourth of its space. This is largely because it does not attempt to be an introduction to programming, but an introduction to C++ for people who've previously programmed in some other language. It has a steeper learning curve, but, for those who can cope with this, it is a very compact introduction into the language. (Historically, it broke new ground by being the first beginner's book to use a modern approach at teaching the language.) [Review]

  • Thinking in C++ (Bruce Eckel) Two volumes; is a tutorial style free set of intro level books. Downloads: vol 1, vol 2. Unfortunately they’re marred by a number of trivial errors (e.g. maintaining that temporaries are automatically const), with no official errata list. A partial 3rd party errata list is available at (http://www.computersciencelab.com/Eckel.htm), but it’s apparently not maintained.

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

Best practices

  • Effective C++ (Scott Meyers) This was written with the aim of being the best second book C++ programmers should read, and it succeeded. Earlier editions were aimed at programmers coming from C, the third edition changes this and targets programmers coming from languages like Java. It presents ~50 easy-to-remember rules of thumb along with their rationale in a very accessible (and enjoyable) style. For C++11 and C++14 the examples and a few issues are outdated and Effective Modern C++ should be preferred. [Review]

  • Effective Modern C++ (Scott Meyers) This is basically the new version of Effective C++, aimed at C++ programmers making the transition from C++03 to C++11 and C++14.

  • Effective STL (Scott Meyers) This aims to do the same to the part of the standard library coming from the STL what Effective C++ did to the language as a whole: It presents rules of thumb along with their rationale. [Review]


  • More Effective C++ (Scott Meyers) Even more rules of thumb than Effective C++. Not as important as the ones in the first book, but still good to know.

  • Exceptional C++ (Herb Sutter) Presented as a set of puzzles, this has one of the best and thorough discussions of the proper resource management and exception safety in C++ through Resource Acquisition is Initialization (RAII) in addition to in-depth coverage of a variety of other topics including the pimpl idiom, name lookup, good class design, and the C++ memory model. [Review]

  • More Exceptional C++ (Herb Sutter) Covers additional exception safety topics not covered in Exceptional C++, in addition to discussion of effective object oriented programming in C++ and correct use of the STL. [Review]

  • Exceptional C++ Style (Herb Sutter) Discusses generic programming, optimization, and resource management; this book also has an excellent exposition of how to write modular code in C++ by using nonmember functions and the single responsibility principle. [Review]

  • C++ Coding Standards (Herb Sutter and Andrei Alexandrescu) “Coding standards” here doesn't mean “how many spaces should I indent my code?” This book contains 101 best practices, idioms, and common pitfalls that can help you to write correct, understandable, and efficient C++ code. [Review]

  • C++ Templates: The Complete Guide (David Vandevoorde and Nicolai M. Josuttis) This is the book about templates as they existed before C++11. It covers everything from the very basics to some of the most advanced template metaprogramming and explains every detail of how templates work (both conceptually and at how they are implemented) and discusses many common pitfalls. Has excellent summaries of the One Definition Rule (ODR) and overload resolution in the appendices. A second edition is scheduled for 2017. [Review]


  • Modern C++ Design (Andrei Alexandrescu) A groundbreaking book on advanced generic programming techniques. Introduces policy-based design, type lists, and fundamental generic programming idioms then explains how many useful design patterns (including small object allocators, functors, factories, visitors, and multimethods) can be implemented efficiently, modularly, and cleanly using generic programming. [Review]

  • C++ Template Metaprogramming (David Abrahams and Aleksey Gurtovoy)

  • C++ Concurrency In Action (Anthony Williams) A book covering C++11 concurrency support including the thread library, the atomics library, the C++ memory model, locks and mutexes, as well as issues of designing and debugging multithreaded applications.

  • Advanced C++ Metaprogramming (Davide Di Gennaro) A pre-C++11 manual of TMP techniques, focused more on practice than theory. There are a ton of snippets in this book, some of which are made obsolete by typetraits, but the techniques, are nonetheless useful to know. If you can put up with the quirky formatting/editing, it is easier to read than Alexandrescu, and arguably, more rewarding. For more experienced developers, there is a good chance that you may pick up something about a dark corner of C++ (a quirk) that usually only comes about through extensive experience.

Reference Style - All Levels

  • The C++ Programming Language (Bjarne Stroustrup) (updated for C++11) The classic introduction to C++ by its creator. Written to parallel the classic K&R, this indeed reads very much alike it and covers just about everything from the core language to the standard library, to programming paradigms to the language's philosophy. [Review]

  • C++ Standard Library Tutorial and Reference (Nicolai Josuttis) (updated for C++11) The introduction and reference for the C++ Standard Library. The second edition (released on April 9, 2012) covers C++11. [Review]

  • The C++ IO Streams and Locales (Angelika Langer and Klaus Kreft) There's very little to say about this book except that, if you want to know anything about streams and locales, then this is the one place to find definitive answers. [Review]

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.

  • cppreference.com (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.

  • The Design and Evolution of C++ (Bjarne Stroustrup) If you want to know why the language is the way it is, this book is where you find answers. This covers everything before the standardization of C++.

  • Ruminations on C++ - (Andrew Koenig and Barbara Moo) [Review]

  • Advanced C++ Programming Styles and Idioms (James Coplien) A predecessor of the pattern movement, it describes many C++-specific “idioms”. It's certainly a very good book and might still be worth a read if you can spare the time, but quite old and not up-to-date with current C++.

  • Large Scale C++ Software Design (John Lakos) Lakos explains techniques to manage very big C++ software projects. Certainly a good read, if it only was up to date. It was written long before C++98, and misses on many features (e.g. namespaces) important for large scale projects. If you need to work in a big C++ software project, you might want to read it, although you need to take more than a grain of salt with it. The first volume of a new edition is expected in 2015.

  • Inside the C++ Object Model (Stanley Lippman) If you want to know how virtual member functions are commonly implemented and how base objects are commonly laid out in memory in a multi-inheritance scenario, and how all this affects performance, this is where you will find thorough discussions of such topics.

  • The Annotated C++ Reference Manual (Bjarne Stroustrup, Margaret A. Ellis) This book is quite outdated in the fact that it explores the 1989 C++ 2.0 version - Templates, exceptions, namespaces and new casts were not yet introduced. Saying that however, this book goes through the entire C++ standard of the time explaining the rationale, the possible implementations and features of the language. This is not a book to learn programming principles and patterns on C++, but to understand every aspect of the C++ language.

TopTalkedBooks posted at August 20, 2017

Your code contains several mistakes. Let's examine them.

        p[5][10] = p[i][j];

Here, you make no change on your array, because just the value of p[5][10] is changed. Furthermore, you access an invalid memory zone, because array indexes go from 0 to size - 1 in C++. So last index is p[4][9].

if(key[j] = n[5][10])

In C++, comparing two values needs two =, because only one is an affectation that results the if to be always true. A tip to remember : two values to compare need two =.

else if(key[j]!=n[5][10])

The same than before, you access invalid memory zone. And are you sure that j is valid, e.g less than 10 ? If not, you do double invalid access.


As search is an array of char, you do an input of only a single char there, which I think is not what you want and that can leads to segfault.

int phone[r][c] = 

Your array is not good, a simple 1-dimension array is enough, not 2-dimensions. Furthermore, 42-54.. does a subtraction, and I think is not what you want.

There are others mistakes. But why not using C++ abstractions, like std::vector, or std::string ? Your life would get so much easier. But I guess you have an old teacher that never took time to learn C++ news, or that is not a good teacher...

As a beginner, I suggest you to read C++ Primer and Programming: Principles and Practice Using C++ to introduce you both programming and modern C++.

Good luck !

TopTalkedBooks posted at August 20, 2017

You might want to try a command-line compiler like gcc, clang or Microsofts C/C++ compiler from the command-line nmake. That can be easier to understand than a complicated gui.

If you want to learn C++ then I recommend the book C++ Primer by Stanley Lippman.

TopTalkedBooks posted at August 20, 2017

They are the copy-constructor and the assignment operator. You should look here for information about the copy constructor, and here for information about operator overloading in general.

However, these are fundamental language constructs that should be covered in any introduction to C++. I (and many others) find that the best way to learn C++ is from a book, so I would suggest picking a beginner's C++ book and working through at least the first few chapters before anything else.

TopTalkedBooks posted at August 20, 2017

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).

  • Use std::array instead of C-array if you know the size at compile-time (and I believe you do).
  • Avoid using namespace std; because it's bad.
  • Be sure that you do well all your includes : #include <string>, #include <vector> and #include <array> if using-so.
  • If you're a C++ beginner, I suggest C++ Primer, updated for C++11. If your a complete beginner, Programming: Principles and Practice Using C++.
TopTalkedBooks posted at August 20, 2017

Welcome to SO.

You have really bundled two or three question together here, but lets have a go at it:

As a third component I need some kind of controlling which links the application's logic with its GUI.

Since you are using Qt, you have a built in answer to this question:

Qt Project-Model/View Programming. To get you started:

The model/view architecture

Model-View-Controller (MVC) is a design pattern originating from Smalltalk that is often used when building user interfaces. In Design Patterns, Gamma et al. write:

MVC consists of three kinds of objects. The Model is the application object, the View is its screen presentation, and the Controller defines the way the user interface reacts to user input. Before MVC, user interface designs tended to lump these objects together. MVC decouples them to increase flexibility and reuse.

If the view and the controller objects are combined, the result is the model/view architecture. This still separates the way that data is stored from the way that it is presented to the user, but provides a simpler framework based on the same principles. This separation makes it possible to display the same data in several different views, and to implement new types of views, without changing the underlying data structures. To allow flexible handling of user input, we introduce the concept of the delegate. The advantage of having a delegate in this framework is that it allows the way items of data are rendered and edited to be customized.

The MVC model, explicitly supported by the QT framework (and possible to implement with other GUI frameworks as well, albeit with more work), is widely accepted as a robust, flexible group of design patterns that affords management and separation of the various application layers, in the manner you are thinking about - so you are on the right track.

The second point may sound a little bit weird, I admit; to put it short, my aims are...

The question of how to set up your source code projects really has nothing to do with your application architecture per se, although these areas generally do intersect such that good project organization facilitates easier implementation of your architecture, and vice- versa. How you organize your project and its various libraries and classes may depend not only the project you're working on now, but on plans for future projects. For example, as you mentioned, you may want to design certain GUI components that you can use for several different applications. If so, you may want to put your GUI modules into a separate reusable generic library that can be used by many applications.

Certain rules, however are applicable across the board and are followed by most experienced developers - here are a few big ones, there are many more:

  • One major class and its friend classes per unit (hpp/cpp file).

  • Be very careful about what you include in header files and what you leave to your CPP files. You will find guidelines here on SO and in any good C++ book on this subject, which is quite important, particularly in complex projects. (From the sound of it - for example your questions about how to use #include and "connect the parts "in code - you need to get a better grasp of the some the fundamentals of C++ programming. Some excellent books are out there - you can find lists on here. C++ Primer (5th Edition) is one of the best places to start.)

  • Break down your classes and libraries in terms of their functionality. Most IDES support virtual sub-folders in your project (not sure about Code::Blocks) to help keep things organized in such manner. This actually gets into fundamental design questions, not merely how to lay out the code in your project.

  • Avoid tight coupling!

    In software engineering, coupling or dependency is the degree to which each program module relies on each one of the other modules.

    Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa. Low coupling is often a sign of a well-structured computer system and a good design, and when combined with high cohesion, supports the general goals of high readability and maintainability.

  • Make good use of namespaces, another great language feature that helps keep things modularized and organized.

In your case it seems that you might want to to do is package your "application logic" into one library, your generic GUI modules into a second, and then a third, thin executable -perhaps simply containing main() and a few lines to kick things off and shut them down when done - that launches the Qt application and intializes the classes in your libraries, which interact using the the MVC model and do the actual work of the application. Three separate modules is not necessary, although it will be more "generic" and reusable" and easier to keep organized that way.

You really have touched on a wide variety of subjects with this question, and again, some of them are related to C++ programming fundamentals, not simply "separating application logic from GUI". Hopefully this answer will help get you moving in the right direction.

An important note: GUI programming is a complete and not particularly easy branch of programming. There are GUI specialists and there are programmers who work with GUI only minimally. (I'm one of the latter group). There is an SE site called User Experience which, although it doesn't deal with GUI programming per se, deals with how users interact with systems, which is directly related to GUI programming techniques. So, when you say "Now I decided to learn GUI programming", know that you are taking on a big job. If you're not really interested in making GUI programming your speciality, you might want to consider using Wizards and pre-fabricated GUI solutions instead of doing it all by hand. QtCreator does provide some such support, as does Code::Blocks. If you intend on making this serious business, there are commercial frameworks available as well. Unless you're doing it simply for the sake of learning, re-inventing the wheel is not recommended for serious commercial programming work.

TopTalkedBooks posted at August 20, 2017

There are a lot of ways in C++ to achieve selection structure.

  1. if else (basically every programming language have it)

if (a)
    //do something
    //do something else
  1. switch control

switch (input)
case a:
     // do something
case b:
     // do something else
     // default when the user input is not expected a or b
  1. labels and goto keyword

int main(void)
    if (a) goto label_a;
    else if (b) goto label_b;
    goto end;
    //something else
    goto end;
    return 0;
  1. Function calls

void first() { /*something*/ }
void second() { /*something else*/ }

int main(void)
    //your previous codes
    if (a) 
        if (b)

    return 0;

More things to read: CPlusPlus Statements and Controls
Or you can invest some money to buy a good C++ Reference books like C++ Primer

TopTalkedBooks posted at December 09, 2017
I'd recommend to choose one of these two books:

Programming: Principles and Practice Using C++, 2nd Ed., Bjarne Stroustrup https://www.amazon.com/Programming-Principles-Practice-Using...

C++ Primer, 5th Ed., Stanley Lippman https://www.amazon.com/Primer-5th-Stanley-B-Lippman/dp/03217...

For a very brief introduction:

A Tour of C++, Bjarne Stroustrup https://www.amazon.com/Tour-C-Depth/dp/0321958314/ref=sr_1_1...

TopTalkedBooks posted at January 21, 2018

Is the book perhaps C++ Primer Plus by Stephen Prata? Then you should throw it away! See e.g. this review for a few reasons why. C++ Primer by Stanley B. Lippman et. al. on the other hand is an excellent beginners book. Also see here for a list of good beginners (and other) books.

TopTalkedBooks posted at January 28, 2018

Not all professors do, unfortunately. Last week I interviewed a potential hire with a masters degree. When asked "What is the Rule of three?" he tried to invent something magical. That said, writing your own vector is not stuff you should be learning in the first week of C++. You aren't coming into programming fresh, so may I recommend supplementing your course materials with the C++ Primer? It takes a bit of time getting you up to speed on the syntax and ideologies before throwing you off the deep end.

TopTalkedBooks posted at March 10, 2018
I found "C++ Primer" by Lippman et al very well written and comprehensive. It includes C++11 features and every chapter has exercises to make sure you understand the content.


TopTalkedBooks posted at April 04, 2018
If you are willing to read a book, I strongly recommend the C++ Primer, 5th ed., by Lipmann et al. [0]

It's a very didactic book, covering C++11 well. Unfortunately it does not cover C++14 or C++17, but if you are just starting out with C++ I don't think that's an issue -- most shops are still on 11 or older, anyways...

[0] https://www.amazon.com/dp/0321714113

Top Books
We collected top books from hacker news, stack overflow, Reddit, which are recommended by amazing people.