This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
How to clear the nested vector?
- From: "Mr. H. Xia" <h dot xia at sheffield dot ac dot uk>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 19 Apr 2005 15:50:55 +0100
- Subject: How to clear the nested vector?
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