views:

1071

answers:

15

So I have been a .Net developer for the past decade and am thinking of learning either C or C++ (with a strong preference to C++).

Does anyone know a good place where a C# fanboi can get started learning C++ (or C)? With so many tutorial sites on the web, it hard to know where to start, and if there is one which might be more accomodating to converting a C# developer.

+3  A: 

C Programming Language , nothing beats the book from the guys that made the language.

Kyle G
I actually own an original print of that book - but I guess its not quite what I am looking for. Or maybe my expectations are wrong.
Ash
This IS the book to learn C in my opinion. Trust us on this one.
Tall Jeff
Why should we trust you if it's just your opinion? ;)
jalf
thanks for the edit jeff ;)
Kyle G
+6  A: 

Work your way through the excellent Andrew Koenig and Barbara Moo book "Accelerated C++" (sanitised Amazon link). This book teaches you C++ rather than assume that you know C and then look at the C++ bits bolted on.

Highly recommended.

HTH

Rob Wells
A: 
Aaron
I'm happy to see someone recommending this book because I just picked up a used copy and haven't read it yet. I'm alarmed to see that it's on its 5th edition and the one I picked up was 2nd. :(
Bill the Lizard
@Bill the Lizard: oh now :(...
Aaron
+11  A: 

First, don't rely on tutorials. That's a bad idea in general, but especially for C++, you're pretty much guaranteed that they'll teach it wrong. (for C, it might work better, since the language is much simpler, and fewer people get it wrong)

Instead, get a good book (like one of those suggested in the other answers), and go at it. Supplement that with browsing the C++ questions here, or on other C++-related websites. (gamedev.net has a surprising number of good C++ programmers on their forums, so reading those can be enlightening too, whether or not you're into games development)

I wrote this answer a while ago, which you might also find useful, although it assumes you're already familiar with the basics of the language.

If you're serious about learning the language, you may want to get hold of a copy of the standard as well. It's not exactly easy reading, and it'll be a while before you're able to find your way in it, but in a language where there's so much you can get wrong, it's a good idea to look things up in the one authoritative source.

It might also make things a lot easier if you don't lump C and c++ together. They are surprisingly different, and finding a C tutorial (or C++ written by a C programmer) will only teach you bad practices. (Just mentioning this because you talked about learning either language) Keep the two languages separate, and focus on one of them. Because while most C code will compile as C++, it's definitely not the right way to go. Good C code is not good C++ code, and vice versa. (and most C++ programmers hate and despise C and vice versa)

I'd recommend learning C++, but there are reasons why C might be interesting too. I'll say that C++ is much more likely to make you cry when you have to use C# again, because while there are a lot of things that C# does better, obviously, there are also some crucial things it is missing, which C++ has had for a decade. It's probably more of an eye-opener than C would be.

jalf
+3  A: 

Please consider also the C++ FAQ Lite http://www.parashift.com/c++-faq-lite/ even if it is not strictly oriented to a C# programmer.

uvts_cvs
+4  A: 

Nothing helped me more than reading solutions of topcoder ( www.topcoder.com ) algorithm competitions and than participating. Start with simple problems, look how it is implemented in C#.NET and compare to C++ solution. Than code the C++ solution by yourself and test it.

Muxecoid
+6  A: 

I like C++ Primer. You might fly through it based on prior experience, so I'd also recommend Effective C++ as a follow-up.

Bill the Lizard
Agreed. C++ Primer is the best I've found to date.
Steve Rowe
Dan
+1  A: 

If you are interested (or not) in GUI programming, the book C++ GUI Programming with Qt has an appendix called "Introduction to C++ for Java and C# Developers". I found it very interesting, since I knew C and Java before starting to learn C++. It teaches you a subset of the C++ language which you can use to get things done with C++ and Qt without having to worry a lot about the more complicated features (which you can learn later by reading a book like Accelerated C++ or, if you are feeling brave, The C++ Programming Language).

jfsantos
+1  A: 

This is the book I used to learn C++:

Teach Yourself C++ by Al Stevens

I read the 1st edition, it's still on my shelf. :)

Andomar
+3  A: 

it says "tutorial" but really it's an overview of the language, straight from cplusplus.com http://www.cplusplus.com/doc/tutorial/

ramy
+3  A: 

If you want to learn C++, i would recommend you a book to read. Good C++ tutorials are rare. There is a good C++ FAQ, explaining many dark corners of C++ and common misconceptions: C++ FAQ Lite

The two books Accelerated C++ and C++ Primer are good ones. I've seen the former recommended very often on valuable sites. I've not read any C++ beginner books that i can recommend, unfortunately.

There is a C++ book online for free, and it's called Thinking in C++. I've heard it is an OK book.

If you have questions while learning, you can always ask at stackoverflow or in the ##c++ irc channel at irc.freenode.org

Johannes Schaub - litb
A: 

A copy of Schildt's 'C++ The Complete Reference' is never far from my right arm. I learned C++ many eons ago by having a decent mentor, a serious project and an early edition copy of that book.

Don't learn GUI stuff yet; programming a simple GUI in any of the C++ toolkits I've used is basically an exercise in instantiating objects and linking them up.

You'll need to get to grips with memory management in C++. That's something you've probably not had to do much of coming from a C# background. New/Delete vs scope-based allocation on the stack. Passing by reference/pointer/copy and the subtle differences

Learn the Standard Template Library (Schildt covers it in sufficient detail) and come to terms with templates in general - they aren't hard once you get them but they can do your head in while learning.

And most of all, have some real-world exercise no matter how simple to do - something you can work toward. Tutorials only go so far to teach you the basics of a language.

Adam Hawes
Schildt's books are of course a byword for technical inaccuracy.
anon
A: 

C++ How to Program (5th Edition)

it covers almost everything

+2  A: 
  1. Read Bjarne Stroustrup's The C++ Programming Language
  2. Go through the Boost source code.
  3. Try to contribute to open source project
  4. solve and submit the problems in topcoder.com
Vinay
+1  A: 

Thinking in C++, by Bruce Eckel. Print version available, but also free download.

theller