S
steflhermitte
Dear cpp-ians,
I have a class:
class mImage
{
public:
//constructors / destructor
mImage(unsigned int nrLayers);
~mImage();
//member functions
...
private:
//data container
unsigned int NbLayers;
vector<Image *> vectorImage;
vector<Image *>::iterator itVectorImage;
//data clearing
void clear();
};
and I have problems with me deconstructor:
mImage::~mImage()
{
clear();
}
void mImage::clear(void)
{
if(NbLayers>0)
{
for(unsigned int l=0;l<NbLayers;++l)
{
delete vectorImage[l];vectorImage[l]=NULL;
}
vectorImage.clear();
}
NbLayers=0;
}
The problem is that apparently the command
"delete vectorImage[l];vectorImage[l]=NULL;"
does not clear the images stored in it, but only the vector itself.
vectorImage is a vector<Image *> and for the class Image I have a
deconstructor command that works perfectly.
Any advice how I should clear the vectorImage together with all the
images that are in it?
Kind regards and thank you in advance,
Stef
I have a class:
class mImage
{
public:
//constructors / destructor
mImage(unsigned int nrLayers);
~mImage();
//member functions
...
private:
//data container
unsigned int NbLayers;
vector<Image *> vectorImage;
vector<Image *>::iterator itVectorImage;
//data clearing
void clear();
};
and I have problems with me deconstructor:
mImage::~mImage()
{
clear();
}
void mImage::clear(void)
{
if(NbLayers>0)
{
for(unsigned int l=0;l<NbLayers;++l)
{
delete vectorImage[l];vectorImage[l]=NULL;
}
vectorImage.clear();
}
NbLayers=0;
}
The problem is that apparently the command
"delete vectorImage[l];vectorImage[l]=NULL;"
does not clear the images stored in it, but only the vector itself.
vectorImage is a vector<Image *> and for the class Image I have a
deconstructor command that works perfectly.
Any advice how I should clear the vectorImage together with all the
images that are in it?
Kind regards and thank you in advance,
Stef