A
Al Newton
My class has this member function:
vector<UniqueCustId*>* CMyClass::GetCustList( void )
{
SYSTEMTIME st;
string strServiceDate;
UniqueCustId* uci = new UniqueCustId;
string strCustNumberOld = "0";
for ( int i = 0; i < m_ParsedRecords.size(); ++i )
{
uci->CustNumber = m_ParsedRecords[ i ].strCustNumber;
strServiceDate = m_ParsedRecords[ i ].strDateOfService;
st = ConvertDateToSystemTime( strServiceDate );
uci->ServiceDate = st;
if ( uci->CustNumber != strCustNumberOld )
{
m_UniqueCust->push_back( uci );
strCustNumberOld = uci->CustNumber;
}
else
{
continue;
}
}
string strCustNbr01 = (*m_UniqueCust)[ 0 ]->CustNumber; // Test
string strCustNbr02 = (*m_UniqueCust)[ 1 ]->CustNumber; // Ditto
return m_UniqueCust;
}
The intent is to loop through m_ParsedRecords (a private member
variable declared as: vector<RECORD> m_ParsedRecords) and store only
unique customer numbers in m_UniqueCust (a private member variable
declared as:
vector<UniqueCustId*>* m_UniqueCust). This last variable is declared
in an initialize function as: m_UniqueRx = new vector<UniqueRxId*>;
My problem is that by setting a breakpoint on the push_back line, I
see unique numbers going into the vector. But ... if I breakpoint the
strings before the return I see only the last number! The function
that calls GetCustList() also sees a vector containing that same
number repeated over and over and over.
I've looked at this code until my eyes glaze and I see nothing wrong
with the logic. Could someone *please* tell me what's wrong. Many
thanks ... Al
vector<UniqueCustId*>* CMyClass::GetCustList( void )
{
SYSTEMTIME st;
string strServiceDate;
UniqueCustId* uci = new UniqueCustId;
string strCustNumberOld = "0";
for ( int i = 0; i < m_ParsedRecords.size(); ++i )
{
uci->CustNumber = m_ParsedRecords[ i ].strCustNumber;
strServiceDate = m_ParsedRecords[ i ].strDateOfService;
st = ConvertDateToSystemTime( strServiceDate );
uci->ServiceDate = st;
if ( uci->CustNumber != strCustNumberOld )
{
m_UniqueCust->push_back( uci );
strCustNumberOld = uci->CustNumber;
}
else
{
continue;
}
}
string strCustNbr01 = (*m_UniqueCust)[ 0 ]->CustNumber; // Test
string strCustNbr02 = (*m_UniqueCust)[ 1 ]->CustNumber; // Ditto
return m_UniqueCust;
}
The intent is to loop through m_ParsedRecords (a private member
variable declared as: vector<RECORD> m_ParsedRecords) and store only
unique customer numbers in m_UniqueCust (a private member variable
declared as:
vector<UniqueCustId*>* m_UniqueCust). This last variable is declared
in an initialize function as: m_UniqueRx = new vector<UniqueRxId*>;
My problem is that by setting a breakpoint on the push_back line, I
see unique numbers going into the vector. But ... if I breakpoint the
strings before the return I see only the last number! The function
that calls GetCustList() also sees a vector containing that same
number repeated over and over and over.
I've looked at this code until my eyes glaze and I see nothing wrong
with the logic. Could someone *please* tell me what's wrong. Many
thanks ... Al