Accelerated C++: Clarification on the wording of exercises

F

Frankie Montenegro

Hi everyone,
I must say that, even though I think
that Accelerated C++ by Koenig and Moo is an awesome
text, the wording of exercises is very poor. I
spend half the time just trying to figure out what is
it they want me to do. Anyway, I somehow managed
untill chapter 5 but now I am hopelessly stuck.
But I am completely lost with the wording of the
following three exercises:
5-2.
Write the complete new version of the student-grading
program, which extracts records for failing students,
using vectors. Write another that uses lists. Measure
the performance difference on input files of ten
lines, 1000 lines, and10000 lines.
My question: What does "complete new version" mean?
What improvements should I make? Maybe use iterators
instead of indices?

5-3.
By using a typedef, we can write one version of the
program that implements either a vector-based solution
or a list-based one. Write and test this version of
the program.
My question: I will assume that this problem refers to
the 5-2 although this is not quite clear. I am sure I
am missing something, but I can't figure out what
else is there to this problem except stating
"typedef vector container;" or "typedef list
container;"
and then using a type "container" in the rest of the code??

5-4.
Look again at the driver functions you wrote in the
previous exercise. Note that it is possible to write a
driver that differs only in the declaration of the
type for the data structure that holds the input file.
If your vector and list test drivers differ in any
other way, rewrite them so that they differ only in
this declaration.
My question:
OK, isn't this what I just did in 5-3?

Thanks everyone for help and apologies for a long-ass
question.
 
K

Karl Heinz Buchegger

Frankie said:
I
spend half the time just trying to figure out what is
it they want me to do.

You are lucky.
I have this in real life with customers everyday :)
But I am completely lost with the wording of the
following three exercises:
5-2.
Write the complete new version of the student-grading
program, which extracts records for failing students,
using vectors. Write another that uses lists. Measure
the performance difference on input files of ten
lines, 1000 lines, and10000 lines.
My question: What does "complete new version" mean?
What improvements should I make? Maybe use iterators
instead of indices?

I don't know what happend in the previous assignments,
I never read that book. But I guess the author
means: Throw away what you have so far and rewrite a new
version. If chapter 5 covered iterators, then I guess
yes: The author wants you to write a version which uses
iterators, especially in the light of the next assignment.
5-3.
By using a typedef, we can write one version of the
program that implements either a vector-based solution
or a list-based one. Write and test this version of
the program.
My question: I will assume that this problem refers to
the 5-2 although this is not quite clear. I am sure I
am missing something, but I can't figure out what
else is there to this problem except stating
"typedef vector container;" or "typedef list
container;"
and then using a type "container" in the rest of the code??

That's what the assignment asks for.
5-4.
Look again at the driver functions you wrote in the
previous exercise. Note that it is possible to write a
driver that differs only in the declaration of the
type for the data structure that holds the input file.
If your vector and list test drivers differ in any
other way, rewrite them so that they differ only in
this declaration.
My question:
OK, isn't this what I just did in 5-3?

There is more then 1 way to skin a cat.
The author wants you to skin the cat exactly his way.
If your result of 5-3 fits 5-4 then there is
nothing you have to do.
 
A

Andrew Koenig

I don't know what happend in the previous assignments,
I never read that book. But I guess the author
means: Throw away what you have so far and rewrite a new
version. If chapter 5 covered iterators, then I guess
yes: The author wants you to write a version which uses
iterators, especially in the light of the next assignment.

It means to start with what's shown in the book and make it complete--that
is, add to it the code that you need in order to be able to compile and run
it. The point of this exercise is for you to measure the performance
difference between vectors and lists.
That's what the assignment asks for.

Whether you need to do anything else depends on how careful you were in your
use of vectors. When you change a vector to the corresponding list, you may
find that parts of your program don't work any more if they depend on
operations that vector provides but list doesn't.
There is more then 1 way to skin a cat.
The author wants you to skin the cat exactly his way.
If your result of 5-3 fits 5-4 then there is
nothing you have to do.

The point of this is exercise is to prepare the ground for templates.
 
F

Frankie Montenegro

Thanks guys.
It makes more sense now. Mr. Koenig, it is good to now you can be found
around here.
Regards,
F.
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top