Declaring Dynamic Lists

Started by
4 comments, last by csolar 21 years, 2 months ago
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.
They can write what they like, so long as I get the royalties.
Advertisement
#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
To be considered a genius you just have to say what everybody knows in a way very few understand
Well I feel foolish. I really hate all those little typos that can sneak up on you like that. Thanks for your help, it works now.
They can write what they like, so long as I get the royalties.
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.
They can write what they like, so long as I get the royalties.
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]
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.

This topic is closed to new replies.

Advertisement