Is a code like this erroneous or ok:
void fun()
{
if ( CONDITION )
{
static MyClass myclass;
...
}
...
}
I.e., can static variables be declared inside local scope?
Is a code like this erroneous or ok:
void fun()
{
if ( CONDITION )
{
static MyClass myclass;
...
}
...
}
I.e., can static variables be declared inside local scope?
It's perfectly valid according to the C++ standard. It may be a questionable thing to do / bad practice in some cases, but it's valid and well defined.
It can, of course. You can easily see that by trying to compile the code.