Name: ________________________________

Honor Code Acknowledgment: ___________________


Random Quiz # 2

CPS 100, Fall 1995

Due: September 21


Problem : (3 points)

Considering the following defintions:

struct Pnode
{
   string name;
   Pnode * next;

   Pnode(string nam, Pnode * ptr = NULL)
   {
     name  = nam;
     next = ptr;
   }

   void Print()
   {
     cout << "\t" << name << endl;
   }
};

struct Snode
{
   int secnum;
   Snode * next;
   Pnode * first;

   Snode(int val, Snode * ptr1 = NULL, Pnode * ptr2 = NULL)
   {
      secnum = val;
      next = ptr1;
      first = ptr2;
   }
     
};
Assume there is a ptr to a linked list of Snodes (each which point to a linked list of Pnodes, students in a particular section). Write the following function, to print out a list of all the students in the course, by sections.
void PrintList(Snode * head)
// postcondition: prints each section number followed by a list of the students
//     in that section.