473,787 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accelerated C++: Clarification on the wording of exercises

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.

Oct 14 '05 #1
3 3390
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
Oct 14 '05 #2
"Karl Heinz Buchegger" <kb******@gasca d.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.
Oct 14 '05 #3
Thanks guys.
It makes more sense now. Mr. Koenig, it is good to now you can be found
around here.
Regards,
F.
Oct 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7914
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 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...
35
7928
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 replied saying it might be outdated, since it was published in 2000, and therefore not worth buying. I don't have the book, I just saw a lot of recommendations for it on the web. Do you think it's outdated? Is a new version planned? What is the best...
27
1959
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 concepts I have not encountered elsewhere, or explain ones I have encountered in ways that add to my understanding. There are a few points of style with which I take issue, such as not consistently using braces around the body of an if or loop,...
14
3099
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 I'm off track here. First of all, the book has been brisk but reasonable up to chapter 5, and then suddenly, it exploded. I had to grit my teeth to get through chapter 6, but the exercises for chap 6 are pretty tame.
1
2721
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 answers to nice exercise sets. Is there anyone who could provide the answers of the exercises in the book? Or an URL will be very much appreciated.
8
4716
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 with the algortihm if you take a vector lets say begin end (one past the last) | | 1 2 3 4 4 6 7 8 9
1
1326
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. In earlier posts to this usenet site, people have recommended that I switch texts to "Accelerated C++" by Koenig and Moo. I have just recently received a desk copy of the text from the publisher and I do believe that the approach taken by the...
0
1067
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
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7517
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.