navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 1 (modified by landauf, 12 years ago) (diff)


TracNav(TracNav/TOCCode)? There is a list template called "tList" use it as follows:

Use in Functions without Global Reference

It you just want to create a new list and just quickly use it make it as follows:

#include <list>                             /* include the header */
#include "debug.h"                          /* for use of PRINTF */
std::list<char*> nameList;                  /* create the new list*/

nameList.push_back("Pumba");                /* add some elements at the end of the list (back)*/

std::list<char*>::iterator element;
for (element = nameList.begin(); element != nameList.end(); element++)
  PRINTF(3)("found name: %s in list\n", (*name));

This code will have an output like this:

found name: Pumpa in list
found name: Mogli in list
found name: Timon in list

You can make lists of whatever you want eg also from WorldEntities:

#include <list>
list<WorldEntity*>* entityList = new List<WorldEntity*>;    /* crete new list*/
entityList->push_back(new WorldEntity());                   /* just adds an new entity */

Now I hear you screem: "ENOUGH"! And you are right…:)

Use in Header Files

If you want a list as a class attribute you have to make a forward declaration of the list:

#inlcude <list>                   /* include the header of the list */

class ExampleClass