I am having a homework that requires me to write a program that could store the data of persons(name,contact number,address) using linked-list. Templates must be used. How could I declare multiple type for the template? And how to store multiple data per node?
Asked
Active
Viewed 2,060 times
1 Answers
1
You do not "declare" multiple types for templates; templates are there for multiple types. Just use it.
Multiple data can be stored in two ways: have the data embedded in your node, or have a pointer in your node that will point to the data.
The first way is easier; the second is probably the right way, but you will need to take into account the question who needs to allocate and free the data - whose ownership the data stored in the node is.

Elazar
- 20,415
- 4
- 46
- 67