Original Post
I'm quite new with using the STL, so I've probably missed something really simple, however i cant for the life of me work out why what i've trying to do doesnt work.
I want to create a vector of pointers to string objects, I've type def'd them like this
typedef vectorand the varibles are stored as public class members like so (the varibles need renaming a bit, but thats the least of my worries right now)StringList; typedef StringList::iterator StringListItor;
StringList *m_szFadeText; // pointer to a vector of string objects StringListItor pFaderWriter; // iterator for the char vector to write to it StringListItor pFaderReader; // iterator for the char vector to read from itwhen my class is constructed i make a new instance of StringList and assign it to m_szFadeText
m_fsStatus = STAT_FREE; m_szFadeText = new StringList; int i = m_szFadeText->size ();m_szFadeText gets a valid pointer back and 'i' correctly gets the size value of '0' now, when i come to use this vector to insert some string pointers into it using push back I use the following code
int i = m_szFadeText->size();
m_szFadeText->push_back(new string("< font . color=#ff0000>Phanbot says : narf. < /font>");
however, for some reason at this point i get an 'access violation' in the size() STL function, the pointer is still the same as it was before.
also, I'm having problems getting the databack again, as this setup
pFaderReader = m_szFadeText->begin();
doesnt let me get to the string object to get teh c_str out of it
(*pFaderReader)->c_str(); is allowed however if I change from a 'vector' to a 'list' (but then it crashes in the section where I push back for another reason.
any help or pointers would be appricatied as its been driving me mad for the last day or so
and some info that might be relavent :
* the code is in a dll, and all the other functions work fine
* I'm using some MFC in this DLL, however the functions that are called which call into MFC have the correct macro at the top.
* I'm using VS.Net
[edited by - _the_phantom_ on August 9, 2002 12:01:25 PM]
[edited by - _the_phantom_ on August 9, 2002 12:36:52 PM]