I'm trying to gain some memory saving in a C++ program and I want to know if I can use blocks as a scope for variables (as in Perl). Let's say I have a huge object that performs some computations and gives a result, does it makes sense to do:
InputType input;
ResultType result;
{
// Block of code
MyHugeObject mho;
result = mho.superHeavyProcessing();
}
/*
My other code ...
*/
Can I expect the object to be destroyed when exiting the block?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…