title: define static string variable in c++ class
body: <p>I have 2 questions:</p>
  
  <p>Why is this possible for an int variable:</p>
  
  <h2>foo.h:</h2>
  
  <pre><code>class foo{
  
       private:
          const static int a = 42;
  };
  </code></pre>
  
  <p>but for a string variable I need to do it this way?</p>
  
  <h2>foo.h:</h2>
  
  <pre><code>class foo{
  
       private:
          static string fooString;
  };
  </code></pre>
  
  <h2>foo.cpp:</h2>
  
  <pre><code>string foo::fooString = "foo";
  </code></pre>
  
  <hr>
  
  <p>And also:</p>
  
  <p>In my particular case foo::fooString should represent a path variable, and I would like that for every object of class foo there were just one instance of foo::string, representing a const value that should never change.</p>
  
  <p>Is there another way to solve this problem?</p>