You are not logged in.

#1 2006-08-30 12:04:42

liem
Member
Registered: 2006-04-29
Posts: 71
Website

Good C++ code to read?

Hi, I'm enrolled in a programming course, intro level C++. However, to learn to write good code you have to read good code.

Soo I wonder if anyone had any tip on a good C++ program one could study?


Sebastian  A. Liem

Offline

#2 2006-08-30 13:16:09

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Good C++ code to read?

Well, that's a tad subjective of course, but over all, you make a good point.

Two books I have are Kernighan & Richie's The C Programming Language and Stroustrup's The C++ Programming Language. The latter is more of a C++ reference book, but does contain lots of example usage, written by the creator of C++, so I find it adequate.

The former book, whilst dealing with C, is a classic and should be in your bookshelf.

Offline

#3 2006-08-30 13:41:14

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Good C++ code to read?

Read code written by phrakture. I'm not sure what projects he's contributed to, but I'm sure its good code.

Dusty

Offline

#4 2006-08-30 14:30:42

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Good C++ code to read?

Oh, I forgot about Andrew S. Tanenbaum - most code he writes and puts in his books seem to be rather lucid for C code. I'm sure his Minix OS is full of exemplary code.

Offline

#5 2006-08-30 14:59:44

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Good C++ code to read?

arooaroo wrote:

Two books I have are Kernighan & Richie's The C Programming Language and Stroustrup's The C++ Programming Language. The latter is more of a C++ reference book, but does contain lots of example usage, written by the creator of C++, so I find it adequate.

K&R is, as arooaroo says, a classic.  But then again, so is Casablanca, and no one watches that anymore 8).  It's worth a read, but don't try following it too closely.

A few smaller C++ books which are well worth the read, besides Stroustup's "The C++ Programming Language (3rd ed)", are "Accelerated C++" (Koenig and Moo), "Modern C++ Design" (Alexandrescu), "Exceptional C++" (Sutter), and "The C++ Standard Library" (Josuttis).

Generally, don't read any "Teach yourself..." or "... in (24 hours|10 days)" type books.  If you want a decent online book, Bruce Eckel's is ok (but not the best): http://www.mindview.net/Books/TICPP/Thi … CPP2e.html

Also, the "C++ FAQ Lite" is always a good reference: http://www.parashift.com/c++-faq-lite/

As for programs to study - boost.org has a set of libraries which are _great_.  There's a problem though.  The external interfaces to these libraries are awesome, but the implementations are made to work on every compiler under the sun, so it's a mess of defines and odd work-arounds in some places (boost::enable_shared_from_this anyone?).  The original wmi window manager had pretty good C++ code, except for the fact that the guy obviously never heard of references.... I haven't looked at it in some time, but the urxvt code was fairly good last I checked.

Offline

#6 2006-08-30 15:02:55

nogoma
Member
From: Cranston, RI
Registered: 2006-03-01
Posts: 217

Re: Good C++ code to read?

arooaroo wrote:

Two books I have are Kernighan & Richie's The C Programming Language and Stroustrup's The C++ Programming Language. The latter is more of a C++ reference book, but does contain lots of example usage, written by the creator of C++, so I find it adequate.

I second both these recommendations, they're both invaluable resources. My university bookstore had a neat bundle deal on both of these (why are CS books usually so pricey roll ?), so you could try the same.


-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/

Offline

#7 2006-08-30 15:32:49

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Good C++ code to read?

nogoma wrote:

(why are CS books usually so pricey roll ?)

Because only a handful of nerds actually buy them and they cost a bundle to produce. (Now that I work in publishing, I understand the pricing better. Although, now that I work for Pearson, I get most books discounted, including the aforementioned books as Pearson owns both Addison Wesley and Prentice Hall! Woo hoo!)

Offline

#8 2006-08-31 00:52:17

chrismortimore
Member
From: Edinburgh, UK
Registered: 2006-07-15
Posts: 655

Re: Good C++ code to read?

nogoma wrote:

(why are CS books usually so pricey roll ?)

Cos uni students need them, and it's fun to make us poor students even more in debt...

I recommend the tutorial www.cplusplus.com, gives you the gist of the language basics, and it's more than enough to get you started.  It isn't extensive, but it's a good starting point, and it's free.


Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB

Offline

#9 2006-08-31 07:28:50

liem
Member
Registered: 2006-04-29
Posts: 71
Website

Re: Good C++ code to read?

phrakture wrote:

K&R is, as arooaroo says, a classic.  But then again, so is Casablanca, and no one watches that anymore 8).

Ha! One of my favourite movies. But yeah I know which books to get, it's only a matter of money. Altrough Modern C++ Design was new to me. I'll try to get my hands on K&R and Stroustrup's The C++ Programming Language ASAP.

phrakture wrote:

If you want a decent online book, Bruce Eckel's is ok (but not the best): http://www.mindview.net/Books/TICPP/Thi … CPP2e.html

Thanks, I'll take a look at it.

phrakture wrote:

Also, the "C++ FAQ Lite" is always a good reference: http://www.parashift.com/c++-faq-lite/

Yep, I read pieces out of it now and then.

phrakture wrote:

The original wmi window manager had pretty good C++ code, except for the fact that the guy obviously never heard of references.... I haven't looked at it in some time, but the urxvt code was fairly good last I checked.

wmi and urxvt, I'll take a look at that.

arooroo wrote:

Oh, I forgot about Andrew S. Tanenbaum - most code he writes and puts in his books seem to be rather lucid for C code. I'm sure his Minix OS is full of exemplary code.

Thanks for the tip, but I'm unsure if studying a OS as first app to be wise. lol


Sebastian  A. Liem

Offline

Board footer

Powered by FluxBB