lundi 24 mai 2021

Does variables creation depend on the scope?

void someFunc()
{
int local0 = 0;
//some code
{
int local1 = 0;
//some code
}
int local2 = 0;
}

All three local variables will be created(allocated on the stack) at the moment of entering someFunc? Or local0 will be created first, then local1, then local1 will be deleted, and then local2 created and on the exit local0 and local2 will be deleted?

Aucun commentaire:

Enregistrer un commentaire