Whats the meaning of code inside { } ? (No the { } of a function )
I have observed this piece of code inside thread examples. I dont understand the meaning of these { } (who are neither beginning nor end of any function or proccess)
qDebug() << "warmup";
{
QTime time;
time.start();
WordCount total = singleThreadedWordCount(files);
}
....
Thanks
Re: Whats the meaning of code inside { } ? (No the { } of a function )
They mark beginning and end of an anonymous scope. "time" and "total" objects will be destroyed right after the scope ends instead of at the end of the function.
Re: Whats the meaning of code inside { } ? (No the { } of a function )
It only group things together, and all inside the brackets get deleted afterwards. It is called local scope. Google for that and you get further informations.
EDIT: too late!
Re: Whats the meaning of code inside { } ? (No the { } of a function )
Thanks.
It is not easy to find this concept at most popular cpp web pages.