On Fri, 24 Oct 2008 17:18:15 +0200, John Doe wrote:
Victor Bazarov wrote:
John Doe wrote:
So here is the update code (without the try for new I will do it later)
but now I get an error :
error C2662: 'NetworkList::Clear' : cannot convert 'this' pointer from
'const NetworkList' to 'NetworkList &'
so I have added const to Clear()...
[snip]
void Clear()
{
for_each( _netlist.begin(), _netlist.end(), DeletePointer());
}
How many times is this function called in your test case?
Most probably two times, right?
And what does it do each time?
[snip]
void OnGettingNetworkList()
{
NetworkList netList = getNetworkList();
}
You return a *copy* of the NetworkList you build in the function.
The first copy dies and deallocates via Clear() all the pointers so
the copy contains invalid pointers, which are deallocated yet again,
that's where the CString fails it assertions, becuase it is already
destroyed.
yes thanks!!!! I knew it was something like that but I couldn't find it.