Say I have a Class called Tensor and in order to fully construct an instance of the class I need to do a bunch of calculations and define auxiliary variables. In that context, I have seen code from somebody else that used a scope as such:
Tensor t;
{
// lots of calculations to define a, b, c, ..
t = Tensor(a, b, c, ..)
}
I think I get the idea: you define the auxiliary variables in a scope because you won't need them again. I'm quite new to C++ and this is the first time encountering this. Typically I see the scope when defining a Class or a function. I've googled and found an example here, under the heading "Point of declaration".
Is this good practice? When should I use it? Should I avoid it? Does it have anything to do with garbage collection?