[TriLUG] OT: C++ question, linked list of objects

Joseph Mack NA3T jmack at wm7d.net
Mon Apr 3 14:34:55 EDT 2006


On Mon, 3 Apr 2006, John Turner wrote:

> I think you are right that he should ask his instructor or 
> even his fellow students. I the recent online courses I 
> have taken at NCSU they had message boards for students to 
> discuss assignments and they were often used to work out 
> issues.

Replies to message board take about a day. I couldn't rely 
on a quick reply on a sunday afternoon. There weren't any 
postings about this homework yet, so it seemed unlikely that 
any of the other students would reply. I did get a reply 
late in the day to say that accessors was a reasonable way 
to go (as much advice as I'm likely to get in this class 
from the instructor), but only after I'd already got the 
same information from this list. I have limited time to do 
homework and it's mostly on sundays. The help I got here 
allowed me to do 4 more hours of homework than I would have 
otherwise.

> All that said I think if Joseph would look at some C++ or 
> even Java programming books he could find some examples on 
> implementing a link list.

Yesterday I said that I can do a linked list with the node 
being a struct (with data and next). With the node being an 
object, I had to use accessors to get info I wanted. 
Compared to getting data from a public struct, this was a 
lot more work, and without any examples of classes using 
classes in the course, it occured to me that I had the wrong 
design. I had asked earlier in the class how to have a class 
use a class, but only got a dephic statement that it was 
done all the time. In response to such a direct request, I 
decided that he wasn't going to tell me.

Trying to figure out what I should be doing, I googled all 
over the place and found lots on lists (all with basic types 
and structs for data) but couldn't find anything I could 
understand for the nodes being an object. At that stage I 
was stuck and posted here. Statements yesterday that 
accessors were an OK way to go, allowed me to keep going. 
The link I got this morning to a page at St Vincent's 
College was helpful, having the node be an object and showed 
me that the submarine should be a separate class to the Node 
class.

> Maybe it isn't in the class text, but it is in many other 
> texts.

The class notes and the class textbook don't have anything 
on list nodes being objects. Most of the learning in the 
class goes on in the homework. I've had to figure out all of 
the 'structors (except the constructor), helpers and the 
overloaded operators myself. This week's homework. although 
nominally about linked lists (which we can do) would appear 
to be on having a class use another class. We aren't given 
any restrictions on how we find these things out. Presumably 
we're supposed to find out any way we can.

Joe

-- 
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml 
Homepage http://www.austintek.com/ It's GNU/Linux!



More information about the TriLUG mailing list