   Can't declare static function/variable
  It used to be that in Visual C++.NET 2003 I could declare a static function or variable in the following manner: public __gc class Game{public:static int location;static void SaveGame();};But now in 2005:class Game{public:static int date;};Gives me the following errors:Error9error LNK2020: unresolved token (0A000290) "public: static int Game::date" (?date@Game@@2HA)Game.objError10error LNK2001: unresolved external symbol "public: static int Game::date" (?date@Game@@2HA)Game.objThe only difference that I can see is that I use the managed C++ for the working version, but I didn't think that would make any difference.  If it does, then I'm in trouble, because I can't get that to work in 2005 either.  What should I do?   
  You need to define static members, like this:class Game{public:static int date;};int Game::date;You could also assign it an initial value:class Game{public:static int date;};int Game::date=-1;;Quote:Original post by CTarYou need to define static members, like this:    class Game    {    public:   static int date;    };    int Game::date; However, "int Game::date;" does not go in the header file, it goes in a source file. It must be defined only once.   ;  Wait, do you want a static C++ variable, or a static CLR variable?   ;  If you wanted that to be a managed class, you probably should be using 'ref class' or 'value class'   ;Quote:Original post by jflangloisWait, do you want a static C++ variable, or a static CLR variable?He says:Quote:The only difference that I can see is that I use the managed C++ for the working versionTo me that sounds like the second version isn't managed C++, if it's then there are alternatives, as RDragon1 pointed out.   ;Quote:Original post by RDragon1If you wanted that to be a managed class, you probably should be using 'ref class' or 'value class'Right:public ref class Game {  public:    static int date;};;Quote:Original post by CTarQuote:Original post by jflangloisWait, do you want a static C++ variable, or a static CLR variable?He says:Quote:The only difference that I can see is that I use the managed C++ for the working versionTo me that sounds like the second version isn't managed C++, if it's then there are alternatives, as RDragon1 pointed out.Oh, you're probably right.   