Why for (class A {} fkldsjflksdjflsj ;;) can compile?
I was putting something wrong in the for loop, but it looks like it can still compile. Then I tried the for loop syntax, and it seems like the following code: defining a class inside a run condition in a loop with some meaningless characters like this might compile.
int main(){
for(class A{} fkldsjflksdjflsj;;)
return 0;
}
also.
for(class A;;)
for(class A{};;)
But not.
for(class A fkldsjflksdjflsj;;)
Why?
source to share
The first part for
can contain a variable declaration. (And some other types of declaration). Fortunately, this is what we have:
class A
{
} zzz;
declares a variable zzz
whose type class A
is a class with no custom members.
class A fkldsjflksdjflsj
fails because it is class A
not defined. But it would be nice if you defined earlier class A
.
source to share