The problem is that you declared the class without a name, but with an alias (typedef). Later, you used the same name to declare without defining another class (I know that it was not an intention, but that the compiler understood it), and its name ran into typedef. When you did the same inside foo (), it was a split region, and that was acceptable. But note that the βclass Sβ inside foo () is NOT the same type as the first line.
source share