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

Joseph Mack NA3T jmack at wm7d.net
Sun Apr 2 20:49:00 EDT 2006


On Sun, 2 Apr 2006, Rodney Radford wrote:

>
> I'd have to disagree with making next public, especially 
> if this is an academic assignment (most profs don't like 
> publics, and for good reason - they make later 
> modification of the classes more difficult due to higher 
> maintenance).

I thought it was about maintaining encapsulation. I assume 
then that higher maintenance is one of the problems of lack 
of encapsulation. So far encapsulation has just been a 
principle.

> How about turning the tables around.. instead of setting 
> the next of the parameter object to point to yourself,

er, um, yourself? (*current).getNext() points to NULL if the 
node is the tail, or undefined if there are no nodes, or to 
the next node if not the last. What is "yourself"?

> set your next to point to the parameter object.  That way 
> you only need to know your own next variable, and nothing 
> needs to be made public.

sorry, this went over my head. Could you explain more. 
Thanks

> Then, to walk the list, expose a method to traverse 
> forward one node.

yes this is what I'm about to do

Thanks 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