Click to See Complete Forum and Search --> : STL and MFC


Ricklyons
April 26th, 1999, 01:16 AM
Anyone out thier have any examples of using any of the STL container class inside of the MFC Document View enviroment? any help would be greatly APP.

Franky Braem
April 26th, 1999, 04:29 AM
Hi,

I'm using stl in my document class. My application has project files. In each projectfile I can have multiple source files. The pointers to these source files are stored in a map like this :


#include <string>
#include <map>

typedef std::string cstring;
typedef std::map<cstring, CSourceFile *> SourceFileMap;




In my document class I declare a member like this :

SourceFileMap m_SourceFiles;



Adding a sourcefile to this map is like this :

m_SourceFiles.insert(std::make_pair(sFileName, pSourceFile));;



I use the insert-method instead of the operator[] because the operator[] does a lot of extra object creations and destructions.

A good resource for learning stl is the Thinking in C++ pages on codeguru : http://www.codeguru.com/cpp/tic/index.shtml

Ricklyons
April 26th, 1999, 11:51 AM
Thanks Frank,
I did get a map to store information? ( thanks to your info)
I'm having a little trouble displaying back in the view ?
Thank again for your help