So I have a singly linked list below that prints out a list of Movie objects in alphabetical order based by the director name. I'm trying to print the first element (the head) and the last element (the tail) in the list but I'm struggling to figure out how. I attempted to print out the head below but it just prints the memory address for some reason instead of the actual object value.
As for the tail, I'm not quite sure how I would access the last element in the list and was wondering if someone could offer guidance or push me in the right direction?
List.cc
1 2 3 4 5 6 7 8 9 10
void List::print() const{
Node* current = head;
while (current != NULL) {
current->data->print();
current = current->next;
}
cout << "HEAD: \n" << head << endl; //prints memory address?
// cout << "TAIL: \n" << head << endl;
}