What kind of programming background do you have (if any) prior to C++? Because in almost all strongly-typed languages with a concept of automatic lifetime management (scopes, etc.) that I have seen, this is not possible. You declare an object in a scope and you use that object within that scope. Objects aren't implicitly shared between different scopes, hence you can't declare something in your main() and expect to be able to use it somewhere else. The global scope is of course the "super-scope" if you will, and all objects declared within it are naturally accessible everywhere where its declaration has effect. This is really really basic programming knowledge (not even specific to C++). If you have difficulties understanding this, you should try to learn a bit more about it before continuing.