Access violation in std::map
I am getting an access violation when tring to access elements in a std::map. The violation occurs on the red line below.
Code:
typedef std::map<wxString, CAccount> mapAccountList;
class CAccountManager : public wxFrame
{
public:
CAccountManager() { Init(); }
~CAccountManager() { }
bool SaveAccount(CAccount &Account);
bool SaveAccountsToDisk();
bool LoadAccountsFromDisk();
int GetNumberOfAccounts() { return m_AccountList.size(); }
const mapAccountList& GetAccountList() const { return m_AccountList; }
private:
void Init();
mapAccountList m_AccountList;
};
bool CAccountManager::SaveAccountsToDisk()
{
// save all accounts to disk
if (m_AccountList.empty() )
return false;
wxFile oFile(ACCOUNT_LIST_FILENAME, wxFile::write);
if (!oFile.IsOpened() )
{
SHOWERROR(wxT("Cannot open output file!") );
return false;
}
mapAccountList::iterator iter;
for (iter = m_AccountList.begin(); iter != m_AccountList.end(); ++iter)
{
SAccountInfo AI = iter->second.GetAccountInfo();
if (!oFile.Write(AI.AccountName) )
{
SHOWERROR(wxT("Could not write to output file!") );
oFile.Close();
return false;
}
}
oFile.Close();
return true;
}
I've been beating my brain for an hour now and still can't figure it out. What am I missing here?!?