0

I've written a program that keeps a linked list of Personnel. The Personnel can be of the type Student(inherited from Personnel) each student has the name and id from Personnel and a Queue of type books. Everything works except it doesn't display the list of books. please offer any help here is my code

struct Book{								//Number 1
	char title[30];
	long dueDate;
	struct Book *next;
	};

	void display(void){								//Display function for part 2.4
	struct Book *temp;
	temp=front;
	while(temp!=0){
		cout<<"The title of the book:\n"<<temp->title<<endl;
		cout<<"The due date of the book is:\n\n"<<temp->dueDate<<endl;
	}

	void display(void){									//Number 3 part 3
		Personnel::display();
		cout<<"Student"<<endl;
		cout<<"Level:\t"<<x<<endl;
		cout<<"Books:\t"<<endl;
		bookQueue->display();
		}

and here's how i'm inserting a book to a particular student

int insert_book(void){							//Number 4 part 2
	Personnel *person=NULL;
	PersonnelNode *node=NULL;
	PersonnelNode *temp, *prev;
	Student *s=new Student();

	temp=head;
	int index=1;
	char name[50], title[30];
	long due;
	cout<<"Enter the name: ";
	cin.ignore();
	cin.getline(name, 50);
	cout<<"Enter the title of the book: ";
	cin.ignore();
	cin.getline(title, 30);
	cout<<"Enter the due date of the book: ";
	cin.ignore();
	cin>>due;
		 while (temp != NULL) {
		 person = temp->getNode();
		 if (stricmp(name,name)==0){
				prev = temp;
				temp = temp->getNext();
				index++;
			}
		 else{
			cout <<"Person to delete is found at index" << index<<endl;
			display_node(person, index);
			s=(Student*)person;							//This changes person from a type personnel pointer to type Student using casting
			s->bookQueue->enqueue(title, due);			//Calls the pointer s to access bookQueue then calls the method enqueue using enqueue
			}
		 
		 }
2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Ancient Dragon
0

with such a small amount of code how do you think anyone is going to know the answer to your question? But my guess is that the display() function is never called.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.