Sign in to follow this  
NickGravelyn

Learning C++ The Right Way

Recommended Posts

NickGravelyn    855
I decided today that I want to (re)learn C++. I'd consider myself pretty much a novice with C++ at this point. I know enough to get some things running, I have a decent grasp of pointers/references (though I still could use a little more work on them), and I get the general syntax. But there's still so much I don't know or don't know fully (like the variations of 'const', for example). I know quite a bit of C# and .NET and now that I have a solid grasp on most of what it takes just to program various things, I decided it's time to get to know C++ so I can continue learning native DirectX without being hindered by unfamiliarity with the language. So my question is where to go to learn C++ the right way? Any books or websites that stand out as great resources for learning C++ without any (or much) misinformation? I've searched around and found things, but I wanted to find out from people who already know C++ where the good references really are. Thanks much.

Share this post


Link to post
Share on other sites
Telastyn    3777
While I normally don't recommend them, the Effective C++/STL books are actually pretty good about condensing the unwritten C++ foibles into text. That info more than anything is what an experienced programmer needs when moving into C++. The C++ Standard Library by Josuttis is something I always recommend.

Share this post


Link to post
Share on other sites
frob    44904
The standard list of books to read are:

# "Accelerated C++" Andrew Koenig and Barabara Moo
# "The C++ Standard Library" Nicolai Josuttis
# "Effective C++" Scott Meyers
# "More Effective C++" Scott Meyers
# "Effective STL" Scott Meyers
# "Exceptional C++" Herb Sutter
# "More Exceptional C++" Herb Sutter

The first, Accelerated C++, will cover all the fundamentals.

The second is an in-depth study of how to use the standard library. Read as much as possible until your brain goes numb, then crack it open every few months and read a chapter. It is an excellent reference.

The Effective and Exceptional series both cover important information, presenting it in bite-size items that are easy to digest.

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Original post by NickGravelyn
I decided today that I want to (re)learn C++. I'd consider myself pretty much a novice with C++ at this point. I know enough to get some things running, I have a decent grasp of pointers/references (though I still could use a little more work on them), and I get the general syntax. But there's still so much I don't know or don't know fully (like the variations of 'const', for example).

I know quite a bit of C# and .NET and now that I have a solid grasp on most of what it takes just to program various things, I decided it's time to get to know C++ so I can continue learning native DirectX without being hindered by unfamiliarity with the language.

So my question is where to go to learn C++ the right way? Any books or websites that stand out as great resources for learning C++ without any (or much) misinformation? I've searched around and found things, but I wanted to find out from people who already know C++ where the good references really are.

Thanks much.
This might seem like kind of a glib answer, but I've found this site to be a good reference for those interested in learning modern and idiomatic C++. As for other references, there are some books that seem to be mentioned often, although I can't call them to mind at the moment [Edit: see above]. I would however strongly recommend the C++ FAQ Lite; reading through it would definitely be a good place to start (and you'll most likely find yourself returning to it often).

As you probably already know, people use the C++ language in a lot of different ways; in particular, a lot of developers eschew its more modern features and approach it more as 'C with classes'. Sometimes this is done for good reasons (e.g. when developing for platforms with limited resources or poor compiler support), sometimes for bad reasons (e.g. 'my cousin's friend read online that the STL is 'teh slow' and should never be used'). If you're interested in improving your C++ skills though, my advice would be to familiarize yourself with modern idioms, libraries, and techniques (Boost/tr1, smart pointers, delegates, lambda expressions, RAII, etc.), and use them (or not) where and when you see fit.

Share this post


Link to post
Share on other sites
Windryder    270
Thank god, here's someone who wants to learn how to write proper C++! C++ is an extremely complex language -- after years of working with it it still surprises me more often than I'd like to admit. :)

The C++ FAQ Lite, which someone mentioned, is a very good resource if you're trying to go beyond the basics of C++. It goes over some common misconceptions and best practices when using the language, and also explains its fundamental concepts. If you are serious about learning C++, I suggest you read it and practice until you feel that you are comfortable with all the aspects of the language that the FAQ covers. In particular, you need to have a strong understanding of pointers (and memory management), references, exceptions, virtual functions, const correctness and RAII to write correct, reliable software in C++. There are certain things in this FAQ that you may want to steer clear of because they are considered flawed or deprecated. For example, in certain places it encourages the use of exception specifications (flawed, often not well supported in modern compilers) and the std::auto_ptr class (use boost::scoped_ptr instead).

Quote:
Original post by jyk:
[...] in particular, a lot of developers eschew its more modern features and approach it more as 'C with classes'.


Incidentally, "C With Classes" was the original name of C++. :)

Share this post


Link to post
Share on other sites
Sillencer    171
Quote:
Original post by frob
The standard list of books to read are:

# "Accelerated C++" Andrew Koenig and Barabara Moo
# "The C++ Standard Library" Nicolai Josuttis
# "Effective C++" Scott Meyers
# "More Effective C++" Scott Meyers
# "Effective STL" Scott Meyers
# "Exceptional C++" Herb Sutter
# "More Exceptional C++" Herb Sutter

The first, Accelerated C++, will cover all the fundamentals.


NickGravelyn, i was in the same situation like you, and now I am reading Accelerated C++... I think it's a really great book...

Share this post


Link to post
Share on other sites
_the_phantom_    11250
Quote:
Original post by frob
The standard list of books to read are:

# "Accelerated C++" Andrew Koenig and Barabara Moo
# "The C++ Standard Library" Nicolai Josuttis
# "Effective C++" Scott Meyers
# "More Effective C++" Scott Meyers
# "Effective STL" Scott Meyers
# "Exceptional C++" Herb Sutter
# "More Exceptional C++" Herb Sutter

The first, Accelerated C++, will cover all the fundamentals.


I'd second this list of books, mostly because this is practically the same list I read with the exception of Accelerated C++.

I also read C++ Templates: The Complete Guide by Nicolai Josuttis & David Vandevoorde which if you want to know more than you ever needed about templates is a good book (and was the final book I read before moving onto Modern C++ Design by Andrei Alexandrescu , a book I brought, read 80 pages of, realised I didn't have a clue what it was on about and sent me on a journey through the books listed above).

Share this post


Link to post
Share on other sites
DevFred    840
Quote:
Original post by phantom
a book I brought, read 80 pages of, realised I didn't have a clue what it was on about

"Exceptional C++" had that effect on me. It's really funny when you think you know a language decently well, and then you read a book that feels like it's talking about a completely different language. What? This is C++?? :)

Share this post


Link to post
Share on other sites
Buster2000    4310
I'd also recommend the same list of books and they are mostly available for very cheap used from amazon.


Really if anybody hasn't read Effective C++ they shouldn't be programming in C++.

Share this post


Link to post
Share on other sites
Gamer Gamester    140
I've read most of and agree with frob's list. I'd also like to add 'The C++ Programming Language, Special Edition" by Bjarne Stroustrup. I'm not sure where it would best fit into your reading curriculum (I read it after reading Effective C++). It's very dense, a heavy read, and doesn't contain as much practical advice like the others. However, it's the only book that really satisfied my need for thoroughness -- after slowly and carefully going through it I finally felt like I had been exposed to every detail (syntactically) of the language (though in terms of potential pitfalls and other practical concerns books such as the others -- as well as loads of hands-on experience -- are necessary).

Share this post


Link to post
Share on other sites
daviangel    604
Quote:
Original post by BeauMN
I've read most of and agree with frob's list. I'd also like to add 'The C++ Programming Language, Special Edition" by Bjarne Stroustrup. I'm not sure where it would best fit into your reading curriculum (I read it after reading Effective C++). It's very dense, a heavy read, and doesn't contain as much practical advice like the others. However, it's the only book that really satisfied my need for thoroughness -- after slowly and carefully going through it I finally felt like I had been exposed to every detail (syntactically) of the language (though in terms of potential pitfalls and other practical concerns books such as the others -- as well as loads of hands-on experience -- are necessary).

I would not consider that book for a novice. It's more of a reference book and any C++ programmer should have a copy of it though sooner or later. I'd recommend his new Swan book instead for a novice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this