Answer to Question #536 in C++ for Mia

Question #536
I need to implement singly linked list for objects of any type. How can I do that?
1
Expert's answer
2010-08-04T11:13:18-0400
Quite simply, you should use the templates to make your list independent of the type of data it stores. And keep a pointer to the next object in the class, which encapsulates the object list. To use a template in a class you have to write the template <class Type> before the class declaration and use the keyword Type instead of the object type you want to store in the list.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS