You can declare a class and an object multiple times, what you can't do is define it more than once.
extern makes this a declaration and not a definition (because there is no initializer):
extern int a;
The body makes your class a definition and not just a declaration. You can define a class once.