I am new at C++, and I'm dealing with the Linked List. However, I'm confused that, while I'm writing a Linked List class. I'm trying to write a code for soccer league. I'm trying to hold each team in a linked list and since each team has players I would like to store them also in a linked list. So the linked list class should have a member to point a linked list which is the same property with the class I'm writing. Can it be possible?
Yes. A node of the teams list would contain a list of players. If you can't use std::list
:
struct Player
{
Player* nextPlayer;
};
struct Team
{
Team* nextTeam;
Player* firstPlayer;
};
I'm pretty sure though that a list is not the optimal structure to model this.