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->clas sHead->nex t;
while (currentStoredStudent->nex t != NULL)
{
while (currentStoredStudent->cur rentStored Class->nex t != NULL)
{
foundClass = FindClass(currentStoredStu dent->curr entStoredC lass,tempH ead);
if (foundClass == NULL)
{
tempClass->previous = lastClass;
}
if (foundClass != NULL)
{
tempClass = foundClass;
tempClass->studentsApplyin g++;
}
currentStoredStudent->curr entStoredC lass = currentStoredStudent->curr entStoredC lass->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.
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->clas
while (currentStoredStudent->nex
{
while (currentStoredStudent->cur
{
foundClass = FindClass(currentStoredStu
if (foundClass == NULL)
{
tempClass->previous = lastClass;
}
if (foundClass != NULL)
{
tempClass = foundClass;
tempClass->studentsApplyin
}
currentStoredStudent->curr
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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->curr entStoredC lass= new ClassNode;
The answer is to change:
ClassNode * currentStoredClass= new ClassNode;
-TO-
ClassNode * currentStoredStudent->curr
ASKER
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?
>>>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 :)
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 :)
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 ??