tags:

views:

660

answers:

1

I'm reading some code that goes:

extern class MyClass : BaseClass
{
    ...
} MyInstance;

Does the extern refer to the class declaration or the instance?

+5  A: 

Instance. Classes cannot be extern.

Although the code smells - this snippet suggests that true declaration of that instance uses a separate class definition. Bad, bad idea - defining the class twice.

Seva Alekseyev
Seva nailed it. Separating the instance from the class definition, the extern class does not compile, but extern MyClass MyInstance does.
Scott S