disclaimer
I'm a programming n00b so I may not know what I'm talking about.
/disclaimer
My question boils down to scopes.
Let say I have code
{
string mystring1;
string mystring2;
string mystring3;
//code dealing with mystring1
//code dealing with mystring2
//code dealing with mystring3
}
versus
{
string mystring1;
//code dealing with mystring1
}
{
string mystring2;
//code dealing with mystring2
}
{
string mystring3;
//code dealing with mystring3
}
Now my guess is that the first block of code uses more memory at any given moment than the second one, and that the second block of code uses more than or equal processing power than the first one.
Are these assumptions true? Which one would you use? And each mystring only has scope within the {} enclosing it right?
I ask this because I have some code that initializes like 10 strings at once (like block 1) and then works with them one by one disjointly from eachother. And when I run my program, it lags a second during the initialization of these strings. So I figured I could rewrite it like block 2 to make it run smoother.