How to clear the nested vector?
Mr. H. Xia
h.xia@sheffield.ac.uk
Tue Apr 19 14:51:00 GMT 2005
Hi, all
I am having problems with clearing a nested vector.
for example:
// face class, a user defined class.
class face{
int *A;
public:
void setup(unsigned n){
if(!A) A = new int [n];
}
~face() {delete[] A}
};
// define the nested vector.
vector< vector<face> > x;
// somewhere
x.resize(100);
// somewhere
face f;
f.setup(5);
x[20].push_back(f);
/*
.
.
.
.
*/
x.clear();
but later when I clear x, the memory is not decreasing...
Can someone tell me what is wrong with my procedure? Many thanks!
Note: on Win32 with either VC6.0 , a simple x.clear() is working, but on Linux no way is working.
-- Johnix
More information about the Libstdc++
mailing list