Can anybody recommend a C++ book? (intermediate/advanced)

J

jklimek

I'm currently a Delphi developer (my day job) but at my company we only
write custom web application/database stuff, so we never really get
into anything advanced. However, I know enough about pointers, objects,
etc, to consider myself an "intermediate" level programmer.

Well, I'm looking to write a game involving physics and multiplayer
capability, and that pretty much means I need C++ if I want to use any
existing engines (eg. HGE, RakNet, ODE, etc).

With that said, I know enough about C++ to write basic programs and I
can even write simple objects but thats about it. When it comes to
multiple inheritance, templates, advanced memory allocation, advanced
pointers, and other advanced C++ stuff I'm pretty lost.

So can anybody recommend me a C++ book?

What concepts are important to learn for writing a multiplayer game in
C++?

Any suggestions available on Safari (www.safaribooksonline.com) is a
bonus Smile

Thanks in advance for any suggestions!
 
R

red floyd

So can anybody recommend me a C++ book?

What concepts are important to learn for writing a multiplayer game in
C++?

Any suggestions available on Safari (www.safaribooksonline.com) is a
bonus Smile

I don't know if its available on Safari, but I'd start with Koenig & Moo
"Accelerated C++". It starts you off the "C++ way", rather than as C
and then adding the classes.
 
T

tragomaskhalos

[snip]
With that said, I know enough about C++ to write basic programs and I
can even write simple objects but thats about it. When it comes to
multiple inheritance, templates, advanced memory allocation, advanced
pointers, and other advanced C++ stuff I'm pretty lost.

No book recommendation but ....
C++ is a big language, but don't fall into the trap of thinking that
you need to know every nuance and corner of it to do productive work.
Eg for templates you probably need to know enough to use the STL but
you don't need to worry about writing your own templates until you've
found your feet a bit. In fact I'd tackle your list thus:
MI - you won't need it.
Templates - see blurb above.
Advanced memory allocation - new and delete, possibly auto_ptr, that's
all. Don't go near writing your own operator new, allocators or any of
that.
Advanced pointers - You'll read lots on this ng about various smart
pointers, but again I'd suggest sticking with raw pointers for
starters.

When you pare down the list like this it all becomes a lot less
daunting - if you know Delphi and have a good intuitive grasp of what a
pointer is then you have a good starting point.

HTH
 
M

mlimber

tragomaskhalos said:
[snip]
With that said, I know enough about C++ to write basic programs and I
can even write simple objects but thats about it. When it comes to
multiple inheritance, templates, advanced memory allocation, advanced
pointers, and other advanced C++ stuff I'm pretty lost.

No book recommendation but ....

Since the OP asked, see accu.org for lots of book reviews. But
_Accelerated C++_ is probably the single best book out there for
learning (or re-learning or expanding one's knowledge of) C++ the right
way.
C++ is a big language, but don't fall into the trap of thinking that
you need to know every nuance and corner of it to do productive work.
Eg for templates you probably need to know enough to use the STL but
you don't need to worry about writing your own templates until you've
found your feet a bit. In fact I'd tackle your list thus:
MI - you won't need it.
Templates - see blurb above.
Advanced memory allocation - new and delete, possibly auto_ptr, that's
all. Don't go near writing your own operator new, allocators or any of
that.

Add to that STL containers (cf.
http://www.parashift.com/c++-faq-lite/containers.html#faq-34.1).
Advanced pointers - You'll read lots on this ng about various smart
pointers, but again I'd suggest sticking with raw pointers for
starters.

I'd suggest just the opposite. Use raw pointers only when you must
(which is usually when you are communicating with a third-party
library). Unlike raw pointers, smart pointers (and other containers
that replace them like std::vector and std::string) are exception-safe
and provide automatic clean-up, which can virtually eliminate memory
leaks. To top it off, a very high quality and well-tested
implementation of several such classes is available for free from
boost.org, and in fact Boost's shared_ptr is part of TR1, which means
it will in all likelihood be an official part of the standard library
at the next revision.

Cheers! --M
 
N

Noah Roberts

tragomaskhalos said:
(e-mail address removed) wrote:

Eg for templates you probably need to know enough to use the STL but
you don't need to worry about writing your own templates until you've
found your feet a bit. In fact I'd tackle your list thus:
MI - you won't need it.

Since C++ does not have a concept of interfaces besides abstract
classes that you inherit from you need MI in *many* normal situations.
There are many cases when you just can't write clean code without it,
you have to sacrifice some form of design to work around not using MI,
and this is just silly. MI isn't very complex anyway, I don't know why
you would want to remove it from a list of things to learn.
Templates - see blurb above.

Well, I put templates on a bit higher priority but in general you're
right.
Advanced memory allocation - new and delete, possibly auto_ptr, that's
all. Don't go near writing your own operator new, allocators or any of
that.

Yep, the default usually works pretty good.
Advanced pointers - You'll read lots on this ng about various smart
pointers, but again I'd suggest sticking with raw pointers for
starters.

Since smart pointers are a lot easier and safer to use I would say
"advanced pointers" are the raw kind. I wouldn't try to write a smart
pointer right away because it requires an advanced level of knowledge
but definately use them.
 
T

tragomaskhalos

Noah said:
Since C++ does not have a concept of interfaces besides abstract
classes that you inherit from you need MI in *many* normal situations.
There are many cases when you just can't write clean code without it,
you have to sacrifice some form of design to work around not using MI,
and this is just silly. MI isn't very complex anyway, I don't know why
you would want to remove it from a list of things to learn.

Fair enough - I was going to point out that MI isn't actually very
hard, but my original comment was based on the observation that MI
isn't available in a lot of languages (including C++ once upon a time)
and they seem to do OK, albeit that some of them do provide interfaces
instead. So I'm not convinced that you can't get away without it, but
would agree that it's conceptually so straightforward that there's no
real value in *not* learning it early on.
Since smart pointers are a lot easier and safer to use I would say
"advanced pointers" are the raw kind. I wouldn't try to write a smart
pointer right away because it requires an advanced level of knowledge
but definately use them.

You and mlimber have both picked me up on this, and I suspect you both
represent the majority expert view so I appreciate I'm on thin ground
here. But my personal preference is to learn the raw concept first (eg
traditional pointers), get to know first hand the challenges involved
(eg ohmygawd I have to keep on top of all these deletion / ownership
issues), and then move onto an abstraction (ie smart pointers) that
saves a lot of grief, when one can appreciate fully the value of it.
The danger as I see it of going straight to the abstraction is that you
can be left without the underlying understanding when something doesn't
work as you'd expect (eg there was a thread a few days ago about
circular references with shared_ptr). Joel Spolsky expresses this far
more eloquently when he talks about "the law of leaky abstractions",
which abound in C++ partly because of all the legacy baggage of C
compatibility; he gives the example of std::string, which works
brilliantly at hiding the novice from some ugly realities until they
try and do string s = "oh" + "oh";.
 
M

mlimber

tragomaskhalos said:
You and mlimber have both picked me up on this, and I suspect you both
represent the majority expert view so I appreciate I'm on thin ground
here. But my personal preference is to learn the raw concept first (eg
traditional pointers), get to know first hand the challenges involved
(eg ohmygawd I have to keep on top of all these deletion / ownership
issues), and then move onto an abstraction (ie smart pointers) that
saves a lot of grief, when one can appreciate fully the value of it.
The danger as I see it of going straight to the abstraction is that you
can be left without the underlying understanding when something doesn't
work as you'd expect (eg there was a thread a few days ago about
circular references with shared_ptr).

Can't the same thing be said for any abstraction, e.g. compilers. Why
use C++ instead of assembly since it only hides the details of how
things actually work? We deal in the abstract because it helps us solve
problems more easily. Granted that it is helpful to know how to use the
lower level elements as well, but that doesn't mean one should *start*
there. _Accelerated C++_ doesn't -- the authors introduce std::vectors
and std::strings first and only in chapter 9 or 10 get to raw pointers
and arrays.
Joel Spolsky expresses this far
more eloquently when he talks about "the law of leaky abstractions",
which abound in C++ partly because of all the legacy baggage of C
compatibility; he gives the example of std::string, which works
brilliantly at hiding the novice from some ugly realities until they
try and do string s = "oh" + "oh";.

Sure, but one can (and should!) still use these imperfect abstractions
to great effect.

Cheers! --M
 
J

Jack G. Atkinson Jr

Just about anything written by Scott Meyers.

Effective C++
Effective STL
More Effective C++

My two cents!


I'm currently a Delphi developer (my day job) but at my company we only
write custom web application/database stuff, so we never really get
into anything advanced. However, I know enough about pointers, objects,
etc, to consider myself an "intermediate" level programmer.

Well, I'm looking to write a game involving physics and multiplayer
capability, and that pretty much means I need C++ if I want to use any
existing engines (eg. HGE, RakNet, ODE, etc).

With that said, I know enough about C++ to write basic programs and I
can even write simple objects but thats about it. When it comes to
multiple inheritance, templates, advanced memory allocation, advanced
pointers, and other advanced C++ stuff I'm pretty lost.

So can anybody recommend me a C++ book?

What concepts are important to learn for writing a multiplayer game in
C++?

Any suggestions available on Safari (www.safaribooksonline.com) is a
bonus Smile

Thanks in advance for any suggestions!


--
------------------------------------------------------------------
Jack G. Atkinson Jr.
(e-mail address removed)
Psa 104:4 He makes His angels spirits,
His ministers a flaming fire.
Luke 12:36-47 - Be ready!
------------------------------------------------------------------
 
N

Noah Roberts

Jack said:
Just about anything written by Scott Meyers.

Effective C++
Effective STL
More Effective C++

My two cents!

Why top post?

Personally I think Sutter's books are better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top