title: How can I give a value to a static variable in a managed C++ class?
body: <p>In VC++ CLR project I have a class temp. I am trying to set the static variable temp1 to 5.</p>
  <p>I am getting a compilation error:</p>
  <blockquote>
  <p>Error 32  error LNK2020: unresolved token (0A0005FB) &quot;public: static
  int temp::temp1&quot; (?temp1@temp@@2HA)  C:\Users\user100\Documents\Visual
  Studio 2012\NewProject 32 bit\create min bars from data2\create min
  bars from data\create min bars from data5.obj</p>
  <p>Error  33  error LNK2001: unresolved external symbol &quot;public: static int
  temp::temp1&quot; (?temp1@temp@@2HA)  C:\Users\user100\Documents\Visual
  Studio 2012\NewProject 32 bit\create min bars from data2\create min
  bars from data\create min bars from data5.obj</p>
  </blockquote>
  <p>How can I fix it?</p>
  <pre><code>class temp
  {
      public:
      static int temp1;
  };
  
  int main(array&lt;System::String ^&gt; ^args)
  {
      temp::temp1 = 5;
  }
  </code></pre>