< Previous | Contents | Next >

The Lobby::Clear() Member Function

The Lobby::Clear() member function removes all of the players from the lobby.

void Lobby::Clear()

{

while (m_pHead != 0)

{

image

image

Introducing the Game Lobby Program 323



image image image


image


image

image

image

image

image

image

Figure 9.15

The list of players just before and just after a player node is removed.


RemovePlayer();

}

}

If the list is empty, the loop isnt entered and the function ends. Otherwise, the loop is entered and the function keeps removing the first Player object in the list by calling RemovePlayer() until there are no more Player objects.