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. 3 3369
Frankie Montenegro wrote: 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.
--
Karl Heinz Buchegger kb******@gascad.at
"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message
news:43***************@gascad.at... 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.
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.
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.
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. 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.
The point of this is exercise is to prepare the ground for templates.
Thanks guys.
It makes more sense now. Mr. Koenig, it is good to now you can be found
around here.
Regards,
F. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin |
last post by:
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...
|
by: Markus Dreyer |
last post by:
I suggested our Librarian for the University Library to buy
Accelerated C++. Practical Programming by Example.
by Andrew Koenig and Barbara E. Moo
http://www.acceleratedcpp.com/
but she...
|
by: Steven T. Hatton |
last post by:
I've finally gotten around to reading Accelerated C++ by Andrew Koenig and
Barbara Moo. There's a lot of good stuff in what I've read so far. Even
though it is _very_ basic, they present some...
|
by: Pete |
last post by:
Is anyone familiar with this book?
Exercise 6-1 of Accelerated C++ asks us to reimplement the frame() and hcat()
operations using iterators. I've posted my answers below, but I'm wondering
if...
|
by: utab |
last post by:
Hi there,
I have been reading Accelerated C++ by Andrew Koenig which is an
excellent way of learning C++ from even the first pages by using the
standard library.
One drawback is that no...
| |
by: utab |
last post by:
Dear all, in a container example, this question is asked in exercises
in Accelerated C++ page 154, 8.8? why dont we use (begin+end)/2 instead
of begin + (end - begin) / 2 is that someting related...
|
by: blangela |
last post by:
I am currently teaching 2 part-time (one evening per week) C++ courses
using the Deitel & Deitel "C++ How To Program" text. Each course is 13
weeks in length, including time for labs and exams. ...
|
by: Lambda |
last post by:
I'm trying to complete all the exercises of Accelerated C++.
I'm not sure what does the exercise 5-5 mean. And how about 5-9?
Thanks
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |