Archived

This topic is now archived and is closed to further replies.

csolar

Declaring Dynamic Lists

Recommended Posts

csolar    122
Somewhere, I saw the something similar to the following passage: std::list& CLASSLIST; I know this created a list of CClasses that you could add or subtract objects, etc. I want to use this idea in my project, but I cant get it quite right. I''m pretty sure I got the code right, but I dont know what Include file I need in order for this to work. I start by typing std:: and a list comes up with 3 different choices, none of which is list. So I try just typing all that in anyway, and It says that list is not apart of std. These are all the includes I have stamped on my project right now: #include <windows.h> #include <mmsystem.h> #include <math.h> #include <stdio.h> #include <list.h> #include <fstream> using namespace std; #include <d3d8.h> #include <d3dx8.h> #include <dinput.h> #include "Engine.h" Any ideas, MSDN was no help again.

Share this post


Link to post
Share on other sites
luxitan    122
#include < list > without the .h

then

std::list< int > a; makes a list of ints called a



To be considered a genius you just have to say what everybody knows in a way very few understand

Share this post


Link to post
Share on other sites
csolar    122
Using that same idea, how do I create an iterator for the list? I can somewhat remember this:

iter = std::list< iter > iterator list.begin()

or something like that. I need something set up so I can loop through the list and do the class functions.

Share this post


Link to post
Share on other sites
Dobbs    164
Declare an iterator like:

std::list<T>::iterator itor;

where T is the name of the appropriate type, int or whatever. Then you can do things like:

itor = someList.begin();
itor = someList.end();
++itor;
*itor;

to manipulate the iterator. Read more at sgi's stl website.

Edit: stupid html, let's try that again

[edited by - Dobbs on January 30, 2003 2:47:19 PM]

Share this post


Link to post
Share on other sites
civguy    308
Read a book that describes STL. Otherwise you''ll only know little of it (only what you know to ask about) and may be using the wrong features for wrong things, and you''ll most likely never end up learning algorithms and other important stuff.

Share this post


Link to post
Share on other sites