how does this expression work inside?
Exactly the same as declaring in a namespace area, except that the name is displayed only within the scope in which it was declared (in this case, the function body). UPDATE: as @Nawaz points out, there are one or two additional restrictions that apply to local classes: they cannot have static data members, and (in C ++ 03, but not C ++ 11) they cannot be used as arguments of type template.
Does it have any negative consequences?
No, except for the scope (which affects only the compilation of code), it is identical to any other class definition.
source share