View Single Post
Old Feb 16th, 2008, 12:46 AM   #2
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4 Jessehk is on a distinguished road
Re: one class to implement a linked list of objects of another class

The general form of a linked list would probably be something like this:
c++ Syntax (Toggle Plain Text)
  1. template <typename T>
  2. class LinkedList {
  3. class Node {
  4. T data;
  5. Node *next;
  6. };
  7.  
  8. Node *head;
  9. public:
  10. // etc
  11. };

Note that a node just has data and a pointer to the next node, while the list has only a pointer to the first node in the list.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote