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