In my class Car. I have this
ID Model Driver
1 Car John
If im using the default print() function from the Linked List, it will show all of em
ID Model Driver
1 Car John
What I want it to show is only the driver
ID Driver
1 John
What should I write to retrieve the driver only?
2)
1 2 3 4 5 6 7 8 9 10 11 12
I want the change the driver data into something else
ID Model Driver
1 Car John
Insert new driver: Popo
ID Model Driver
1 Car Popo
Driver changed!
What should I write to change the driver without having
to reconstruct the whole element inside the node?
1. Your LList::print could take a function pointer with 0 as default. If pointer is 0, you print as you do now. If pointer is not 0, then you call the function with the ptr->info as parameter.
2. You LList must have a method to reference single node, and the node type must allow change of member.
The front() is just an alternative for *(begin()). Begin returns iterator. Iterator can advance to point other elements, but then dereference would return reference to that further object.
You could consider a LList member T& itemAt (int atIndex) const;
PS. If the user gives an invalid atIndex, then your insertAt will crash.