Well, Elysia is correct and you are misinterpreting your example.
The code in your example is valid because it does not make use of any forward declarations, and presents a complete class definition before func() attempts to instantiate your class.
The code;
Code:
class Foo {
public:
Foo();
~Foo();
};
is neither a forward declaration nor an incomplete class declaration. It is a class
definition.
The subsequent implementations of the constructor and destructor are also definitions of those (special) functions. The compiler does not need to see those definitions (in fact, they can be put into separate source files) because the previous class definition declares them, so they may be called.