Fog Creek Software
Discussion Board




How Should a novice start learning C++.

Hi,
    I am a young software professional who wants to learn C++. I have tried reading several books. Then I came to this site and read the discussion and I was impressed by the depth of knowledge and commitment. I don't want the name of the books. What I wanted to know is that what thought process should i nurture to learn the subtelities of C++.

Waiting for Response,
Regards,
Aeron

N Aeron
Friday, March 12, 2004

Some advice:

- Always try out things that you learn. Not only things that you read, but also the possible permutations/combinations around that. E.g. if you read about constructors, try using them in various scenarios like with parameters, using inheritance, making virtual and any other random idea that comes to your mind.

- After doing that, reason out the behaviour in each case. I.e. if some program produced some output, why did it produce that output. Is it a documented feature, an undocumented feature, a bug; basically what was the concept behind that output. This is important because you might forget the exact code and output, but you should remember the concept that produced the output.

HTH

T-90
Friday, March 12, 2004

I always found this book http://www.research.att.com/~bs/dne.html helpfull  in understanding the "why" questions on some of the oddities in C++.

Just me (Sir to you)
Friday, March 12, 2004

"Accelerated C++" and "Essential C++" are IMHO perfect. Wish I had learned it with those...

http://www.amazon.com/exec/obidos/tg/detail/-/0201485184/103-9123437-3304642?v=glance
http://www.acceleratedcpp.com/

_
Friday, March 12, 2004

I don't know your background or how much OO experience you have, but if you are totally green, then:

Learn Java (or C#) first.

The benefits of OO and good OO design are best illustrated by a rich, well-designed class library.  Java and C# have these.  C++ doesn't.

David Jones
Friday, March 12, 2004

Whatever you do, don't learn C first.

C will only teach you bad habits, and bad ways of working.

(Note: writing the C way in C is fine if that's your bag; writing C++ likes it's C is not).

Mr Jack
Friday, March 12, 2004

I've heard good things about this book

http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470863986.html

Mike
Friday, March 12, 2004

The most important thing is to get your hands dirty with some code. I recommend against things that are tied to a certain compiler, such as the Borland or Visual C++ specific books. These are great tools, but learn the language, not the tool.

I also strongly advise you to understand the Standard Template Library and how to use it. Once you're up to it, I also recommend learning everything about templates that you can. It's all the rage at the moment, and there's definitely a lot of power available through templates.  My own lack of understanding is holding me back from some jobs I'd like to have.

Clay Dowling
Friday, March 12, 2004

Since (almost) everyone else is mentioning books :)

- C++ Primer, by Stanley B. Lippman & Josée LaJoie
- Thinking in C++, by Bruce Eckel (www.bruceeckel.com)

Paulo Caetano
Friday, March 12, 2004

You don't learn the subtelities of C++ first, you learn the basics first.

The only way to learn a language is to use it, so pick a small project and write it in C++.

Clutch Cargo
Friday, March 12, 2004

> I don't want the name of the books. What I wanted to know is that what thought process should i nurture to learn the subtelities of C++.

C++ has several kinds of "subtlety":

* Subtelties which you can't begin to understand, because you're unable to read them, because you don't understand the syntax: for example, "templates", "overloaded operators", etc.

* Subtleties which if not understood cause your program to behave unexpectedy and incorrectly: for example, "copy constructors", "virtual destructors", etc.

* Subtleties which if understood cause your program to behave correctly with less coding effort: for example, "smart pointers", "encapsulation", etc.

* SUbtleties which are related to the C++ libraries that you're using: for example "why std:auto_ptr<> isn't appropriate for using as elements in a collection", "how do I use VC++/MFC "Wizards'", "what's a good library to use to implement multi-threading", etc.

* Subtleties which aren't necessarily specific to C++ but are more related to object-oriented programming in general: for example, "design patterns", "analysis", etc.

> what thought process should i nurture

If I had to pick a single thought process, it would be "how does this feature of (or use of, or example of) C++ help me to write (or design, or maintain) a (or this) C++ program 'well'?"

Christopher Wells
Friday, March 12, 2004

The C++ Annotations is an excellent online book:

http://www.icce.rug.nl/documents/cplusplus/

i like i
Friday, March 12, 2004

"What I wanted to know is that what thought process should i nurture to learn the subtelities of C++."

Like most of the others here, I'd encourage you to avoid the subtle areas in your initial studies, and learn the well understood bits.  But you didn't ask that....

Learning C++ by doing is, I think, a dangerous approach.  I reach this conclusion from years of experience dealing with code written by those who learned in precisely that way.  The common denominator in most of this code is that it seems to do what was intended most of the time.

http://www.accu.org/bookreviews/public/reviews/0hr/beginner_s_c__.htm
http://www.accu.org/bookreviews/public/reviews/0hr/advanced_c__.htm

At the other end of these two links are lists of books "Highly Recommended" by the ACCU.  I encourage you to stay in these lists until you have compelling reason to do otherwise.

Also, start reading news://comp.lang.c++.moderated on a regular basis - I encourage staying in the moderated group to get the best signal.

My own approach, which seems to have been effective, was to start by reading Scott Meyers.  That is, I learned the common mistakes and how to avoid them FIRST, then later learned the basics.  So I got a lot out of "Windows Hothouse", because I kept looking at the code samples and seeing mistakes that I recognized from Meyers.

For the real subtleties of the language, crank the warning level of your compiler to the max.  You might even consider investing in Lint.  Each time a new warning appears, go research it.

Most important principle to keep in mind: code will often work, without being correct. 

Danil
Friday, March 12, 2004

> My own approach, which seems to have been effective, was to start by reading Scott Meyers.

Meyers' (mistakes to avoid) were the second books that I read; but the first was "Thinking in C++", because I needed to learn C++ syntax (how to read C++) before I could read Meyers.

Christopher Wells
Friday, March 12, 2004

I always liked the Dietel and Dietel books because they could both be read, and served as a reasonable reference for the future.

Elephant
Friday, March 12, 2004

The "Thinking in C++" books are available on-line, downloadable and in print form.

http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

Bill W. Davis
Friday, March 12, 2004

Actually I don't think C is a bad place to start learning how to program.  It very closely abstracts the underlying machine.  Why does C get such a bad rep?  Hell with a struct of function ptr's it can do 90% of what I want C++ for. 

C++ can create some really bad habits as well (ie super deep inheritence hierarchies).  Want to write some code no one will understand try using boost::tuples and boost:any... etc. 

I'm going to go out a controversial limb here and say inheritence is one of the most overrated language features ever invented.  It causes insanely tight coupling which is almost never good.

Interfaces: great.  Love 'em.  Inheritence: If I have to look another class that inherits from CWnd 6+ levels up, I'm going to scream. 

christopher baus (www.baus.net)
Friday, March 12, 2004

C can be both
(A) a reasonable place to start learning to program
(B) a very bad place to start learning C++

Notice that MrJack carefully drew this distinction.

Danil
Friday, March 12, 2004

http://www.topcoder.com
Get an account and try to solve some puzzles. Then learn design and development from the books and build something.

Tom Vu
Friday, March 12, 2004

> I'm going to go out a controversial limb here and say
> inheritence is one of the most overrated language features
> ever invented.  It causes insanely tight coupling which is
> almost never good.

Ooooh, how cutting-edge... except everyone's been saying that for years, starting with Stroustrup...

_
Saturday, March 13, 2004

Good then, maybe someone at Sun or Microsoft will start listening.  Personally I don't think neither Java nor .NET are good examples of class frameworks, as another poster claimed.

christopher baus (www.baus.net)
Saturday, March 13, 2004

I'll back up the comment about not learning C first. Learn modern C++ from the large scale down. Also don't be put of by the 'C++ is hard' brigade, it just takes abit of dedication, nothing worth doing is easy.
Once you have C++ you have a very powerful tool, Java and C# will be easy. Check out www.boost.org.

Craig
Saturday, March 13, 2004

*  Recent Topics

*  Fog Creek Home