views:

237

answers:

9

I'm something of a new, reluctant convert to C++ from a Pascal, Ruby, and PHP background. I haven't worked with Pascal since a few months of torture with "Delphi Turbo;" since then I've practically been eating and sleeping Ruby and PHP. I'm already well acquainted with object oriented programming and many various subjects.

My main trouble is that I already know the rudiments of C/C++ programming, less the actual experience of working with C++. I worked with C for long enough to realize that even without macros, etc, I didn't want to work with it. (Some of the disgust was from maintaining a CGI application in C, when accustomed to Pascal's automatic string management.) I know just enough C++ to be dangerous to myself and anyone else unwitting enough to use my "code."

I'd really like to work up to a good enough understanding of C++ to use libraries like Crypto++ and Boost without major problems or in-depth knowledge of the language's intricacies. I just need to figure out how to work with C++ without killing myself (either with C++, or with the long-standing dislike that I'm already battling).

What are effective resources that will teach me C++ without assuming that I must be retaught all basic programming? I'd rather not relearn concepts that I already know, unless the paradigm in C++ is significantly different. I'm also learning on my own time, so don't recommend me a book complex enough to need a guru to explain to me, please! And I have an effective budget of $0 for learning C++, so please keep suggestions to quality online resources or books common enough that I could likely find them at the library.

+5  A: 

Read Effective C++ by Scott Meyers - it's a good guide for getting past the basics of C++ and showing how to write and use "correct" C++ code

Paul Betts
Not forgetting More Effective c++ and Effective STL
Stephen Nutt
A: 

Here is a link to a question with answers that should help you.

http://stackoverflow.com/questions/1227764/i-need-to-improve-my-c-skills-fast-is-this-realistically-possible/1227805#1227805

For effective stuff you can find online Cplusplus.com has a pretty good reference and information.

If you can find the book "C++ Common Knowledge" (Stephen Dewhurst) at the library or cheaply online, I would add that to the list posted on the StackOverflow link above as well as "The C++ Programming Language" (Stroustrup). Going through the questions under the C++ tag right here on SO should give you some good pointers and code examples to get you on your way.

RC
+4  A: 

The C++ FAQ Lite is a great resource.

Alan
+2  A: 

I can give you a couple of keywords you might want to research in more detail:

  • RAII (Is pretty much the technique that ensures you don't have to worry about memory leaks. Very convenient)
  • Generic Programming (The STL in particular. Experiment with iterators and the standard library algorithms, and see just how powerful these abstractions are. They're a key part of what I like about C++)
  • Functors (Perhaps too simple on their own, but the way they can be used instead of function pointers with the algorithms mentioned above is interesting)

And just get familiar with templates, and "mild" forms of template metaprogramming. (Traits classes, for example, and (partial) specializations.

And just keep an eye on the C++ questions here on SO. A lot of interesting topics are regularly brought up.

But the best advice is probably to keep it completely separate from C. Forget everything you learned about how to use C. It either doesn't apply in C++, or leads to inferior code that is harder to read and maintain.

It's an interesting language in its own right, and has a number of unique features. Leverage those, and it can actually be fun to work with C++. Treat it as an overengineered Java, PHP or C, and it'll just make you want to throw up.

jalf
+1 one for the advice to forget C when doing C++.
sbi
+4  A: 

I highly recommend Stroustrup: The C++ Programming Language (Third Edition). As the author of C++ he is the authority on the language, and the book is useful as a reference as much as it is for learning the language. It's common enough that most good general purpose libraries will have a copy. He goes into quite some depth on all the features of C++, including explanations of why certain design decisions were made in the language. Personally, I think this is the best book around for programmers to learn C++.

Once you have a good grip on core C++, David Abrahams and Aleksey Gurtovoy's book, C++ Template Metaprogramming, goes into further depth and provides many examples of how C++'s template system allows you to perform complex compile-time programming, a highly valuable skill these days. This one is a little less common but you can probably find it at a university library.

David Claridge
Ouch, interlibrary-loan tells me that 2 copies were lost, 2 cannot be checked out, and 1 is already out; we'll see about it in the (near) future.
The Wicked Flea
+2  A: 

You need to write code. A lot of code in C++. There is no substitute. You also need to read good code.

I agree with the suggestion for Scott Meyers' books though. Those are pretty good.

Part of your learning will be the leap from procedural programming to OO.

Tim
Tim, I write very little OO nowadays, Sure, I do inheritance, but only little of this is polymorphic. C++ is a multi-paradigm language and the ability to mix many paradigms is one of its greatest strengths.
sbi
The person was asking about C++ and mentioned boost.If you want to use C++ like it is C, fine, but I think others want to use the better features of the language.
Tim
+1  A: 

I would highly recommend the book "C++ Common Knowledge" by Stephen C. Dewhurst. Don't know if it's common enough to be found at the library (it's not at mine, but my library sucks for computer books that aren't 5-10 years out of date), but it does an excellent job of taking the complex aspects of C++ and making them easy to understand, without dumbing anything down for beginners. Definitely worth the investment.

To quote from the back of the book:

This book is for you if

  • You're no "dummy," and you need to get quickly up to speed in intermediate to advanced C++
  • You've had some experience in C++ programming, but reading intermediate and advanced C++ books is slow-going
  • You've had an introductory C++ course, but you've found that you still can't follow your colleagues when they're describing their C++ designs and code
  • You're an experienced C or Java programmer, but you don't yet have the experience to develop nuanced C++ code and designs
  • You're a C++ expert, and you're looking for an alternative to answering the same questions from your less-experienced colleagues over and over again

C++ Common Knowledge covers essential but commonly misunderstood topics in C++ programming and design while filtering out needless complexity in the discussion of each topic. What remains is a clear distillation of the essentials required for production C++ programming, presented in the author's trademark incisive, engaging style.

goldPseudo
Yes this really is a good/useful book. I happen to like Dewhurst's books, for some reason many don't. Then again, I find Stroustrup's writing to be impenetrable, and many rave about it.
Dan
A: 

Here's a list of good C++ books which teach you C++ rather than basics of programming.

Technowise
A: 

Sit down and write some C++ code.

navigator