Accelerated C++ Sample Solutions

M

Martin

I am reading through Koenig and Moo's "Accelerated C++" and attempting the
exercises. Are there any sample solutions somewhere? It's all very well me
doing a solution, which seems to work, but for all I know it can be riddled
with undefined behaviours and bad C++. The alternative is to post my
solution to every single exercise and ask for guidance, but I actually think
that is counter-productive and tantamount to spamming anyway. A set of
sample solutions would be ideal. Do they exist?
 
D

David White

Martin said:
I am reading through Koenig and Moo's "Accelerated C++" and attempting the
exercises. Are there any sample solutions somewhere? It's all very well me
doing a solution, which seems to work, but for all I know it can be riddled
with undefined behaviours and bad C++. The alternative is to post my
solution to every single exercise and ask for guidance, but I actually think
that is counter-productive and tantamount to spamming anyway. A set of
sample solutions would be ideal. Do they exist?

This was recently asked in alt.comp.lang.learn.c-c++. The thread is here:
http://tinyurl.com/ro2q

DW
 
A

Andrew Koenig

"David White" wrote
Thanks for that David. It seems from that thread the answer is "no."
Shame.

Indeed it is. However, coming up with a good set of solutions is an
enormous amount of work, because not only must the solutions be exemplary,
but they must be accompanied by explanations of what the decisions were
behind those particular solutions. Perhaps for that reason, the books I
know of that give solutions to the problems in well-known C++ books are
usually written by someone other than the original book's author(s).

Having solutions readily available is not an unalloyed benefit, either. The
problem is that some readers will be tempted to read the solutions rather
than solving the problems on their own.

Still, perhaps it might make sense to consider putting some hints about
particularly interesting questions on the book's website. I'll think about
that.
 
J

jeffc

Andrew Koenig said:
Having solutions readily available is not an unalloyed benefit, either. The
problem is that some readers will be tempted to read the solutions rather
than solving the problems on their own.

Still, perhaps it might make sense to consider putting some hints about
particularly interesting questions on the book's website. I'll think about
that.

That would be the best of both worlds. Interestingly, there are often
questions here regarding problems to work on. e.g. "I have been programming
for a little while and have written some very simply programs. Can anyone
suggest some 'assignments' for me to try?" That is of course what the
exercises are there for. On the other hand, giving a clue as to what you
had in mind (specifically what features from the chapter you wanted to
exploit or combine, or what points you were referring to) could be very
helpful.
 
M

Martin

Andrew Koenig said:
Indeed it is. However, coming up with a good set of solutions is an
enormous amount of work, because not only must the solutions be exemplary,
but they must be accompanied by explanations of what the decisions were
behind those particular solutions. Perhaps for that reason, the books I
know of that give solutions to the problems in well-known C++ books are
usually written by someone other than the original book's author(s).

Do you mean you set the Exercises without attempting the solutions yourself?
:) You must have had an idea of what the resulting code would look like.
Some of the Exercises are straightforward and providing answers would be
almost trivial: for example, deciding whether the program is valid or not or
Exercise 0-9 "What's the shortest valid program?" Naturally, there are far
more complex Exercises in the book, and they are probably the ones we're
discussing.

I've tried solutions to the earlier ones in the book, and I honestly don't
know whether they're good, full of undefined behaviours, bad practice, or
what. The fact they compile and produce the correct results doesn't exclude
that of course. I didn't want to post every attempt on here either as it's
tantamount to spamming.

Having solutions readily available is not an unalloyed benefit, either. The
problem is that some readers will be tempted to read the solutions rather
than solving the problems on their own.

Kernighan & RItchie's "The C Programming Language" had exercises. A set of
solutions was published in Tondo & Gimpel's "The C Answer Book." I found
both books an enormous aid in helping me to learn C.

You're right of course, some people would look at the solutions before
attempting the questions. I wouldn't because I actually want to learn C++.
But there you go...

Still, perhaps it might make sense to consider putting some hints about
particularly interesting questions on the book's website. I'll think about
that.

That'll certainly be a step in the right direction.

Martin
 
P

Paul M. Parks

I am reading through Koenig and Moo's "Accelerated C++" and attempting
the exercises. Are there any sample solutions somewhere? It's all very
well me doing a solution, which seems to work, but for all I know it
can be riddled with undefined behaviours and bad C++. The alternative
is to post my solution to every single exercise and ask for guidance,
but I actually think that is counter-productive and tantamount to
spamming anyway. A set of sample solutions would be ideal. Do they
exist?

I've begun that task.

http://www.parkscomputing.com/acpp/

PMP
 
A

Andrew Koenig

Do you mean you set the Exercises without attempting the solutions
yourself?

In general, yes.
:) You must have had an idea of what the resulting code would look like.

Of course.
Some of the Exercises are straightforward and providing answers would be
almost trivial: for example, deciding whether the program is valid or not or
Exercise 0-9 "What's the shortest valid program?" Naturally, there are far
more complex Exercises in the book, and they are probably the ones we're
discussing.

Right.

In general, there's a big gap between a solution to a problem that's good
from a programming standpoint and one that's good from a teaching
standpoint. Ideally, one would like sample solutions to be ones that, in
addition to being correct, teach something useful to whoever reads them.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top