CS210 Lab: STL Lists Prelab


Prelab Questions:

The following are some questions that you can answer prior to the lab.
  1. Given the following template class for linked lists:
    template <class T>
     class LinkedList; 
    
     template <class T>
     class ListElement 
     { 
           T datum; 
           ListElement* next; 
           ListElement (T const&, ListElement*); 
    
           friend LinkedList <T>;
     }; 
    
     template <class T>
     class LinkedList 
     { 
           ListElement<T>* head; 
     public: 
           LinkedList (); 
           ~LinkedList (); 
           bool IsEmpty () const; 
           T const& First () const; 
           T const& Last () const; 
           void Prepend (T const&); 
           void Append (T const&); 
           void Extract (T const&); 
           void Print (); 
     }; 
    		
    How would you declare a linked list of
    1. integers
    2. characters
    3. floats
  2. If you were given the following data type:
    struct DataType 
    {
        int position;              // (Key) Packet's position w/in message
        char body[packetSize];     // Characters in the packet
        int getKey () const
            { return position; }   // Returns the key field
    };
    
    
    
    and had declared an object: DataType currPacket
    Could you have the following statement:
    cout << currPacket;
    If not, how could you fix this statement?

For answers, click here
Back to STL Lists Lab click here

CS Dept Home Page
CS Dept Class Files
CS210 Class Files

Copyright: Department of Computer Science, University of Regina.