I have the following structures and declarations:
struct ResultStruct // Individual Event Finisher
{
int eventYear; // Year of result info
int eventOAll; // OverAll Finish position
int eventD_P; // Division Place
long eventTime; // Finish Time
string resEvent;
} resultWork;
typedef list<ResultStruct> ResultList;
ResultList resultList;
ResultList::iterator resIter;
struct FinisherStruct // Individual Finisher data
char finGender; // gender
int finCount; // # Finishes
long finLink; // unique Finisher (link) Id
string finName; // Finisher Name (Last, First)
string finDoB; // (derived) DoB via Age/Year
ResultList resList; // Finisher's events details
} finisherWork;
vector<FinisherStruct> finVect;
vector<FinisherStruct>::iterator flIter;
I populate the data like this:
finisherWork.finName = "Washington, George";
finisherWork.finDoB = 1940;
finisherWork.finLink = 17;
finisherWork.finCount = 0;
finisherWork.resList.clear(); // !!! Problem on reuse!!!
...
resultWork.eventTime = 3456;
resultWork.eventD_P = 3;
resultWork.eventOAll = 27;
resultWork.eventYear = 2010;
resultWork.resEvent = "Boston Marathon";
finisherWork.finCount++;
finisherWork.resList.push_back(resultWork);
I have discovered that the data in "resList" is incorrect when I
populate the object with different data...because reusing this data
value, even though I "clear()" it, is using the same memory address over
and over. I realize that I must use a pointer here and reallocate it,
but I don't know how to do it (e.g. "new something" and a redefinition
of "resList").
IOW, I must define the "ResultList resList" so that I can allocate
new memory data each time I populate the data object. Please advise.
TIA
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com