c++freak:
I meant any keywords, not all keywords.
viz. template, typename, class, register, etc.
BTW thanks for trying to stay away from C vs. C++! I just want people to discuss C++ by its features and not get into a language war.
Whirlwind:
If you go into your compiler documentation, there should be an explanation of each STL class and its member functions, plus some examples (which can be accessed through the help for the member functions). You do have to hunt around a bit for it though.
Basically, STL is a lot of typedefs and some very useful classes. They start small (like pair, auto_ptr, etc.) and keep building upon those objects. It is a very well designed library - plus it reduces the size of my code quite a bit. Instead of writing a map class myself to hold the images in my map editor, I use this code:
map<unsigned int, image> images;
which enables me to place an int in each of my map tiles and objects, indicating which image to use when I want to draw that tile or object. I then go to the map of images, give it the ID, and I get the corresponding image. It''s quite a lot better than tracking objects based on their pointers, I assure you:
display_surface.copy(images[ID], tile.x, tile.y);
Not only that, but I am using vectors to hold the tiles and objects, which are -fast-. I''d show how small the actual source for the map editor is, but I can''t release it to the public. I just wanted to give an example of how it could be used.
Also, when I wrote a font engine, I used this code in each font object:
map<char, image> images;
which allows me to go through an STL string, use it as an array, and print out the corresponding image from the map class. That is:
for( int x=0; x < mystring.size(); x++ )
display_surface.copy(images[ mystring[x] ]);
Of course, you need to add code to keep track of the new position of each letter as you are drawing it, but you get the idea: find the current char, then get its image, and copy it to the screen.
Then there is always the optimization stage. Since I had the same amount of characters (256) and the same range (0-255), I just used a vector that contained 256 images instead of mapping characters to an image with the map class.
IMHO, since all programming is manipulating data, and STL is a powerful tool for manipulating data, STL is invaluable for C++ programming. Of course, that''s just my opinion.
Happy Coding!
- null_pointer
Sabre Multimedia