Ok so I updated my findStudent code to:
Code:
void findStudent(const LinkedList<Student> &list)
{
int id;
cout << "Please enter student ID number: ";
cin >> id;
Student temp{ id };
list.retrieve(temp);
cout << temp;
}
And now my retrieve function looks like:
Code:
template <class TYPE>
TYPE LinkedList<TYPE>::retrieve(TYPE &dataIn) const
{
Node<TYPE> *pTemp = front;
while (pTemp != nullptr && pTemp->data < dataIn)
{
pTemp = pTemp->next;
}
if (pTemp != nullptr && pTemp->data == dataIn)
{
dataIn = pTemp->data;
}
return dataIn;
}
I tried to make the parameter TYPE &dataIn a constant but my program would not work. But now I have another problem. Instead of printing out the student's id, name, gpa, and major it only prints out the id. This info is stored in the structure Student as:
Code:
struct Student
{
int id;
char name[50];
float gpa;
char major[6];
//overloaded operator functions
}
How can I get it to display the student's entire record?