vector problem
I have just recently change some code to use std::vector instead of CArray.
It saves the data and displays the data after the file is opened again. The
problem starts when I try to add another object to the vector array. First I
load the data from the document to a ListCtrl on a form, where I can add
elements to the vector. I also use the vector to get a pointer to each of the
objects in the vector and add it to each of the ListCtrl items through
SetIttemData(). After items are added to the list control and the submit
button is press, the code goes through the list and if it has a valid
pointer, it will copy over the data at the location. If it has a NULL for a
pointer, I use push_back to enter a newly created object to the vector. This
is where it does not work. I put a break point in the copy construtor and
found by stepping through the code, once I use push_back, the copy
constructor is called more times than the once. In fact it looks like it is
copying the vector all over again and some. Here is my copy constructor in
case it is the problem.
//////////////////////////////////////////////////////////////////////////////////////
// copy constructor
CLeagueEstab::CLeagueEstab(const CLeagueEstab& cpy)
{
m_Address = cpy.m_Address; // CString
m_City = cpy.m_City; // CString
m_Name = cpy.m_Name; // CString
m_Phone = cpy.m_Phone; // CString
m_State = cpy.m_State; // int
m_Zipcode = cpy.m_Zipcode; // CString
} // copy constructor
any ideas?
--
Just Al