Link to home
Start Free TrialLog in
Avatar of pimonkey
pimonkey

asked on

Nested Linked List Sort/Search

I have two linked list nodes:

struct ClassNode
     {
                //Other variables not important
          ClassNode * next;
          ClassNode * previous;
     };

struct StudentNode
     {
          apstring fullName;
          ClassNode * classHead;
          StudentNode * next;
          StudentNode * previous;
     };

Previously in my program, a linked list of Students was created and the variable "studentHead" was passed to function CountClasses, by reference.  studentHead is the head pointer for the created linked list.  (Function CountClasses moves through the Student list and creates/addsto another linked list of Class Names)

Here is the important section of CountClasses:

ClassNode * currentStoredClass= new ClassNode;
     StudentNode * currentStoredStudent = new StudentNode;
     currentStoredStudent = studentHead->next;
     currentStoredClass = currentStoredStudent->classHead->next;

while (currentStoredStudent->next != NULL)
     {
          while (currentStoredStudent->currentStoredClass->next != NULL)
          {
               foundClass = FindClass(currentStoredStudent->currentStoredClass,tempHead);
               if (foundClass == NULL)
               {
                    tempClass->previous = lastClass;
               }
               if (foundClass != NULL)
               {
                    tempClass = foundClass;
                    tempClass->studentsApplying++;
               }
               currentStoredStudent->currentStoredClass = currentStoredStudent->currentStoredClass->next;
          }
          currentStoredStudent = currentStoredStudent->next;

---------------
The error recieved is that currentStoredClass is not a member of StudentNode.   I want to assign currentStoredClass to the ClassNode within the first Student in the Student Linked List.   this probably is not the best way, but I am open to any suggestions.
ASKER CERTIFIED SOLUTION
Avatar of akshayxx
akshayxx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
does it point to the head of the Student List ?
OR its the headPointer itelf .. so it will point to the first student itself..

by first student .. do u mean the one at the end of the list ?? or the one at the head of the list ??
Avatar of pimonkey
pimonkey

ASKER

though I truely value your commitment to my problem, I have found the answer.  My lack of information made it very difficult to figure out what was going on.

The answer is to change:

ClassNode * currentStoredClass= new ClassNode;
 -TO-

ClassNode * currentStoredStudent->currentStoredClass= new ClassNode;



Nice enthusiasm, Too bad I did not provide all information needed and made it confusing.

mmmm...points taste good yes?
>>>mmmm...points taste good yes?
not really .. what tastes better is that u solved something , which other people had hard time doing .. points is a token which tells how hard and important was it for the asker :)
and 'the expert' can also feel being valuable :)