tags:

views:

394

answers:

7

SO . I want to learn C++ .I didn't read any book on C++. Some people talk about "modern C++" and C++ programming with C influence. So which book is completely out of date?

+1  A: 

C++: The Core Language is a good one. If you are coming over from C this is the book to get. It does not waste any time.

andreasw
+5  A: 

For learning as a beginner:

If you've never programmed: C++ How to Program

If you have some programming experience: C++ Primer

If you're quite competent in programming, especially a C derived language: Thinking in C++

After that, you should go with Effective C++ and More Effective C++.

I assume that by Modern C++ you mean Modern C++ Design. That book is a classic but is for advanced students of C++.

Jason
+1 just for the recommendation of Scott Meyers' books. Both are excellent, even if they have been out since 1995.
duffymo
In addition, Herb Sutter's books Exceptional and More Exceptional C++ are strongly recommended.
Prasoon Saurav
A: 

c++ how to program ,deitel

It is simple(rarley boring) but teaches really well.

rahmivolkan
Personally, I think the Deitel books are awful.
duffymo
+1  A: 

The author of "Thinking in C++" has not worked with C++ for 10 years. It is an outdated book.

Nemanja Trifunovic
What concepts are in the language now that are not covered by that book that a beginner should know when first starting out?
Jason
Outdated? Example?
Kornel Kisielewicz
+2  A: 

A very good introductory text to modern C++ is Accelerated C++ by Andrew Koenig and Barbara E. Moo. It starts right away to use the C++ standard library (instead of starting from a C-like C++) and covers the subject in a well-motivated order (instead of just putting one artificial example after another in an effort to cover all the features of C++).

jk
A: 

Unfortunately with C++ there is a shedload of books NOT TO READ. C++ was the most popular OO language in its time and it brought OO programming to the masses, for this reason there are hundreds of books based either on c++ coupled with a certain technology or C++ focused at the wrong parts of programming, or in extreme cases to teach everything about programming in one book with C++ as the target language.

So, your question should simply be what books do I read, as most books on C++ are suboptimal by far. There are many threads on SO with books to read.

Suggested strategy

You should first learn OO from another language, then learn C and then C++. Or skip step one and learn C first -- to start you about what C book to read -- well the K&R book is your first step -- and that's an outdated book you should read :D.

Hassan Syed
I don't think there's any use in learning C first. Why risk picking up C habits if you don't need them?
Georg Fritzsche
I guess this is a controversial issue. But C++ is a total minefield with all sorts of quirks -- these quirks are present because of being a tack-on to C. If one knows the limitations brought forward by C it is easier to accept and remember the quirks present and what to do with them. Plus modern C++ usage is to produce better engineered embedded / game / system code, therefore there is a lot to be gained from going C to C++ rather than direct C++ or 4th gen to C++ as you will bring the too-high perspective with you.
Hassan Syed
+4  A: 

For beginning C++ programmers I usually recommend "Accelerated C++." This book has several things going for it. It teaches good style and proper technique from the beginning. It jumps right to doing things the right way rather than teaching the outdated way first as some books tend to do. (For example some books don't introduce vector or string classes until after covering C-strings and arrays. Arguably C++ programmer need to know about C-strings and arrays, but teaching them first encourages rather than discourages their use.) It covers useful stuff as opposed to stuff of historical interest. This empowers new programmers to be able to do interesting things early.

The drawback (or is it a feature?) of "Accelerated C++" is that it is short. I doesn't cover a semester's worth of material. This is perfect for most beginners because they can get a true feel for C++ without feeling overwhelmed.

Also for beginners is Bjarne Stroustrup's "Programming -- Principles and Practice Using C++". Note that this is intended as a college text book. (For a first class in programming.) This fills a great need because although there are many C++ text books, I didn't find a single one that I was willing to use when I taught C++. (This was before Stroustrup's text was published.) Because this is a text book it may be a bit daunting for individuals wanting to learn C++ on their own, which is why I usually recommend "Accelerated C++" to get started.

(I assume the question poster meant "up to date" rather than "out of date.") Both of these books are up to date in technique and through the 2003 standard.

The question poster asked about "modern C++" and programming with a "C influence" with good reason. These are important pitfalls. C++ is a very complicated tool that came out of the C programming community. Early attempts to use and teach C++ were strongly influenced by this and resulted in what some have called "programming C++ with a C accent." This trend is exacerbated by the idea some have that C++ students should "learn C first." This is a good idea only if you want to learn C. Otherwise you have introduced yourself to a number of habits that you will have to unlearn when learning C++.

Neither of these books have this problem. They both use C++ as it is meant to be used, not as a "better C".

There are many poorly written books that introduce C++. I'll illustrate common problems with a book that has been (wrongly in my opinion) recommended as an answer to this question. I was quite familiar with Deitel and Deitel's "C++ How to Program" up through it's third addition. (I've never seen any of the later editions, although the publisher's web site says they are up to the seventh addition and has its table of contents on-line.) This book is often recommended because it is popular and was the book that introduced many students to C++. Students learning something for the first time have a wonderful insight into the quality of a book. They may be well equipped to determine if a book is clear or confusing. Bu they can't tell you if what they are being taught is factually correct or good practice. If the book contains errors or teaches poor practices, students will discover this only much later and with pain (or worse yet, they may never discover this).

I was less vexed about the factual inaccuracies that I found than by the fact that the book just didn't teach good programming. I will say that I didn't find many inaccuracies and by the seventh edition, we'll give them the benefit of the doubt that those have been caught by now. But I'm less hopeful that the authors are imparting good style.

I will share one example that I think illustrates my point about both factual errors and poor programming. In one snippet of example code was something like this:

 Foo* foo = new Foo;
 assert(foo);

Now a beginner won't see a problem with this and will likely copy it. After all it is an example out of a text book. But an experienced C++ programmer will know that in standard C++ this assertion is useless. It cannot fail because new never returns zero (it throws instead). But the larger sin in my eyes is teaching beginners that the correct way to check for runtime errors is to use assert().

I said earlier that I would give the authors the benefit of the doubt that factual errors have been addressed. Given that, should I reconsider this book with a recommendation? No. The on-line table of contents gives the game away. Although this edition covers more information than the editions that I'm familiar with, it is clear that the authors have continued the pattern of simply appending new material to the end of the book rather than integrating it into the book. (Some of the new material is in on-line chapters.)

The new edition has twenty-two (paper) chapters, but it doesn't cover STL containers until chapter twenty-two. (To be fair, in the new edition there is a section on vectors in chapter seven that wasn't there before. This section makes up a tenth of the chapter which they call "Arrays and Vectors.") It doesn't cover the string class until chapter eighteen.

Does it really matter what order material is covered? I believe that the order of material presentation is one of the biggest issue in introducing C++ to beginners and this book completely fails. Imagine all the example code and exercise questions that are presented that cannot use std::string or STL containers. Have the authors re-written the examples and exercises after chapter seven to use std::vector where appropriate? Possibly, but I'm not optimistic.

In "Learning Standard C++ as a New Language" Stroustrup points out that one of the difference between teaching C and C++ is that trivial C++ programs can be robust in the face of bad input. To make C programs handle these situations requires a lot of complication that can distract beginners. (You can read about it here: http://www2.research.att.com/~bs/new_learning.pdf ) But simple C++ programs have this advantage only if you introduce students to things like std::string very early.

Another way of looking at this is that teaching students to solve problems using (only) C-strings and arrays is teaching them to solve problems in a way no professional would. Now we don't expect student code to look exactly like code written by professionals, but students can and should be given the tools to write code that is robust enough to ship and powerful enough to be interesting.

Good luck with your study!

Jon Kalb