M
Mike Copeland
The following program does not update the STL map object on the 2nd
call to "find" it. That is, I find the object after I've stored it, I
modify an object - but when I try to (re)insert it the map object isn't
changed. Please advise. TIA
#pragma warning (disable:4786)
#include <map>
#include <string>
#include <time.h>
using namespace std;
typedef struct ChipRec
{
int bibNum;
short dbeAge, ndfAge, gruAge;
short dbeGender, ndfGender, gruGender;
char dbeRCode, ndfRCode, gruRCode;
char entECode;
bool timeWritten;
bool dbeMatched, ndfMatched, gruMatched;
bool dbeLoaded, ndfLoaded, gruLoaded;
string dbeName, gruName;
string ctsKey;
string teamId;
} tData;
tData tWork, qWork;
typedef map<int, ChipRec> BCI;
BCI bci;
map<int, ChipRec>::iterator bciIter;
int bibNumber = 11;
int main()
{
bci.clear();
tWork.dbeGender = tWork.gruGender = tWork.ndfGender = 'M';
tWork.dbeAge = tWork.gruAge = tWork.ndfAge = 47;
tWork.dbeRCode = tWork.gruRCode = tWork.ndfRCode = 'a';
tWork.dbeName = "George Washington";
tWork.teamId = "NONE";
tWork.ctsKey = "PXZ";
tWork.entECode = 'A';
tWork.bibNum = bibNumber;
tWork.gruMatched = tWork.ndfMatched = false;
tWork.gruLoaded = tWork.ndfLoaded = false;
tWork.timeWritten = false;
tWork.dbeLoaded = true;
bci.insert(BCI::value_type(bibNumber, tWork));
int bibNum = 11;
map<int, ChipRec>::const_iterator wIter;
wIter = bci.find(bibNum);
if(wIter != bci.end())
{
qWork = wIter->second;
qWork.dbeAge = 74, qWork.dbeName = "Abe Lincoln";
bci.insert(BCI::value_type(bibNumber, qWork));
}
wIter = bci.find(bibNum);
if(wIter != bci.end())
{
tWork = wIter->second;
}
return 0;
}
call to "find" it. That is, I find the object after I've stored it, I
modify an object - but when I try to (re)insert it the map object isn't
changed. Please advise. TIA
#pragma warning (disable:4786)
#include <map>
#include <string>
#include <time.h>
using namespace std;
typedef struct ChipRec
{
int bibNum;
short dbeAge, ndfAge, gruAge;
short dbeGender, ndfGender, gruGender;
char dbeRCode, ndfRCode, gruRCode;
char entECode;
bool timeWritten;
bool dbeMatched, ndfMatched, gruMatched;
bool dbeLoaded, ndfLoaded, gruLoaded;
string dbeName, gruName;
string ctsKey;
string teamId;
} tData;
tData tWork, qWork;
typedef map<int, ChipRec> BCI;
BCI bci;
map<int, ChipRec>::iterator bciIter;
int bibNumber = 11;
int main()
{
bci.clear();
tWork.dbeGender = tWork.gruGender = tWork.ndfGender = 'M';
tWork.dbeAge = tWork.gruAge = tWork.ndfAge = 47;
tWork.dbeRCode = tWork.gruRCode = tWork.ndfRCode = 'a';
tWork.dbeName = "George Washington";
tWork.teamId = "NONE";
tWork.ctsKey = "PXZ";
tWork.entECode = 'A';
tWork.bibNum = bibNumber;
tWork.gruMatched = tWork.ndfMatched = false;
tWork.gruLoaded = tWork.ndfLoaded = false;
tWork.timeWritten = false;
tWork.dbeLoaded = true;
bci.insert(BCI::value_type(bibNumber, tWork));
int bibNum = 11;
map<int, ChipRec>::const_iterator wIter;
wIter = bci.find(bibNum);
if(wIter != bci.end())
{
qWork = wIter->second;
qWork.dbeAge = 74, qWork.dbeName = "Abe Lincoln";
bci.insert(BCI::value_type(bibNumber, qWork));
}
wIter = bci.find(bibNum);
if(wIter != bci.end())
{
tWork = wIter->second;
}
return 0;
}