Reputation: 65
For Example, let's say you have:
Class Test
{
public:
Test();
private:
int x = 0;
int y = 3;
}
You declare an instance of Test using something like
Test * RRR = new Test();
Let's say somewhere down the line you type
delete RRR;
Does this also delete the memory that x and y took up?
Upvotes: 0
Views: 100
Reputation: 1445
the short answer is yes, but strictly speaking, x and y are not deleted. The memory they tak will be released, because they are data members of the struct.
Even you don't define a destructor, the compiler will synthesized a default destructor for you, which will release the memory that the struct takes.
Upvotes: 1