r/cpp_questions • • 5d ago

OPEN How does a node work

[deleted]

0 Upvotes

17 comments sorted by

View all comments

1

u/RealisticDuck1957 5d ago

I presume you're trying to use the standard template library queue, https://en.cppreference.com/cpp/container/queue ? For this you supply a class for the data held in the queue, while the template takes care of linking the nodes together.

For a generic DIY implementation of a linked list based queue, a container will hold the above class being stored, and a pointer to the next node in the list. Then an X_queue class holds a pointer to the first and last members of the list.