Reputation: 21911
Does it make any sense of declaring objects or refrences in a destructor of a class in C++?
I mean
class A
{
A()
{
}
~A()
{
//Declaring refrences or objects here //
}
}
Upvotes: 1
Views: 107
Reputation: 50752
you can declare any type of variable if you need it, but you should delete it properly like in the other cases. what is the case?
Upvotes: 0
Reputation:
If you need local variables in your dtor, then use them. There is no special restriction; the body of a dtor is treated like the body of any function. If you don't need them, then it wouldn't make sense to declare them.
Upvotes: 5