I have this struct and I initialize it in my linked list class, but I am not sure how to display it:
struct CourseData {
string CourseID, MaxCapacity, CurrentCapacity ;
string CourseName, InstructorName, CourseSection, CourseLocation, ListOfStudents;
};
class CourseNode {
private:
CourseData elem;
//
CourseNode* next;
public:
CourseNode(CourseData elem) : elem(elem)
{}
friend class Courses ;
};
class Courses {
private:
CourseNode *head;
public:
Courses();
~Courses();
What should I change to this code? It outputs an error:
void Courses::display() const
{
CourseNode *ptr=head;
cout<<"Head->";
while(ptr!=NULL)
{
cout<<ptr->elem<<"->";
ptr=ptr->next;
}
cout<<"Null"<<endl;
}
Aucun commentaire:
Enregistrer un commentaire