hi, I coded this:
Ne::Ne(): {
printf ("costructor \n");
_w = new double[10];
}
Ne::~Ne() {
printf ("destructor \n");
delete[] _w1;
}
class Lay {
std::vector <Ne> _ne;
...............
}
//in main.cpp
lay._ne.resize(2); //here crash
Ne::Ne(): {
printf ("costructor \n");
_w = new double[10];
}
Ne::~Ne() {
printf ("destructor \n");
delete[] _w1;
}
class Lay {
std::vector <Ne> _ne;
...............
}
//in main.cpp
lay._ne.resize(2); //here crash
To copy to clipboard, switch view to plain text mode
I can see that when resize is called happen this:
costructor
destructor
destructor
and crash......
costructor
destructor
destructor
and crash......
To copy to clipboard, switch view to plain text mode
I wonder why does 'destructor' start? and 2 times? crash reason maybe can be destroy 2 times the same portion of memory.....but ....
thanks
Bookmarks