Feb 3, 2013 at 8:53am UTC
Dear Cplusplus' users,
I create and use the following vector:
std::vector< bool > component_select(1);
component_select[0]=true;
And now I would like to use its destructor. I have tried different options such as:
~component_select();
or
~component_select;
or
component_select.~Vector();
or
std::vector< bool > ~component_select;
but nothing seems to work.
I would be really grateful if someone could help me.
Thanks in advance.
Best,
Isi.
Feb 3, 2013 at 9:32am UTC
> And now I would like to use its destructor.
Why do you want to do that? The destructor would be invoked by the implementation when the life time of the object is over.
To remove all elements, use component_select.clear() ;
Feb 3, 2013 at 10:35am UTC
Thank-you for your answer.
On one hand, and if I wanted to release memory and I wanted to eliminate it by myself because I knew when the life time of the object is over, couldn't I do it?
On the other hand, I wanted to use the destructor because I wanted to define it again with more elements, I mean:
std::vector< bool > component_select(1);
component_select[0]=true;
.
.
.
Using its destructor , that I don't know how to call it, I would do:
std::vector< bool > component_select(3);
component_select[2]=true;
.
.
.
Thanks in advance.
Best,
Isi.
Feb 10, 2013 at 9:33am UTC
Dear JLBorges,
thank-you for your answer and your recommendation.
Best,
Isi.