When does this object instance get cleaned up?
The situation I'm asking about is in the comments. Basically, when does "s" of type Stupid get cleared?
Code:
class Stupid
{
int size;
int *array;
public:
Stupid(){}
Stupid(int arraysize)
{
size = arraysize;
array = new int[size];
}
~Stupid()
{
delete array;
}
};
class Container
{
private:
Stupid s; // declared here. I assume this calls the default constructor?
int size;
public:
Container(int stupidsize)
{
size = stupidsize;
s = Stupid(size); // instantiaed here. What happens to the original s?
}
};