Quailman
May 9th, 2008, 06:50 PM
Hello! I have been teaching myself C++ for about half a year now. I started out with John Kopplin's Computer Science Lab. Now I am working my way slowly through Bruce Eckel's Thinking in C++. I've hit a few walls on some of the example programs in the book since I don't have anybody to go to for help, but I've been able to work out my problems for the most part. However, I am pretty well stuck on one of the problems right now and I was hoping someone here would be able to guide me.
Your sticky on posting homework problems has scared me from posting my question for a day and a half, but I am at the point where I must ask ;). I don't expect to be spoon fed, but a bit of guidance would be appreciated. Anyway, on to the problem.
I am stuck on example 16 in chapter 4.
http://www.codeguru.com/cpp/tic/tic0059.shtml
Here is a link to the Stash program referred to in the question:
http://www.codeguru.com/cpp/tic/tic0057.shtml
Ok, I have spent at least 2-3 hours trying to solve this, all to no avail. My main difficulty is in understanding exactly what Eckel is asking me to do. When he referrs to changing the "underlying data structure" of Stash, does he mean to use a vector instead of a struct to construct a Stash-like object, or does he mean to use a vector inside of the struct instead of the data members in the original Stash struct?
Not really knowing what to do, I tried both approaches. I thought the first was the most logical, but I kept getting a strange compiler error for my code before I even got far. The second approach yielded the same results.
If someone will clarify for me what they think Eckel is asking I will give this another shot. I am very persistent, so even if I hit another wall I will probably work another 2+ hours trying to solve this. The only thing is, I don't want to waste that much time on an aproach that isnt going to work anyway. I know learning programming is all about trial and error, but that much error is unacceptable to me ;).
Sooooo, if someone could answer my question from paragraph 3, I would greatly appreciate it. I will try to solve this problem using the information you give, and I will post my code if I continue to have aneurysm-inducing problems. I would have posted my other code, but I was so frustrated I scrapped it xD.
Sincerely,
Quailman, the lost programming noob.
Your sticky on posting homework problems has scared me from posting my question for a day and a half, but I am at the point where I must ask ;). I don't expect to be spoon fed, but a bit of guidance would be appreciated. Anyway, on to the problem.
I am stuck on example 16 in chapter 4.
http://www.codeguru.com/cpp/tic/tic0059.shtml
Here is a link to the Stash program referred to in the question:
http://www.codeguru.com/cpp/tic/tic0057.shtml
Ok, I have spent at least 2-3 hours trying to solve this, all to no avail. My main difficulty is in understanding exactly what Eckel is asking me to do. When he referrs to changing the "underlying data structure" of Stash, does he mean to use a vector instead of a struct to construct a Stash-like object, or does he mean to use a vector inside of the struct instead of the data members in the original Stash struct?
Not really knowing what to do, I tried both approaches. I thought the first was the most logical, but I kept getting a strange compiler error for my code before I even got far. The second approach yielded the same results.
If someone will clarify for me what they think Eckel is asking I will give this another shot. I am very persistent, so even if I hit another wall I will probably work another 2+ hours trying to solve this. The only thing is, I don't want to waste that much time on an aproach that isnt going to work anyway. I know learning programming is all about trial and error, but that much error is unacceptable to me ;).
Sooooo, if someone could answer my question from paragraph 3, I would greatly appreciate it. I will try to solve this problem using the information you give, and I will post my code if I continue to have aneurysm-inducing problems. I would have posted my other code, but I was so frustrated I scrapped it xD.
Sincerely,
Quailman, the lost programming noob.