Search code examples
c++symbolsextern

Extern keyword and unresolved external symbols


I drew a little graph in paint that explains my problem:

But it doesn't seem to show up when I use the <img> tag after posting?

Graph:

http://i44.tinypic.com/103gcbk.jpg


Solution

  • You need to instantiate the database outside of main(), otherwise you will just declare a local variable shadowing the global one.

    GameServer.cpp:

    #include GameSocket.h
    Database db(1, 2, 3);
    int main() {
       //whatever
    }