title: Initialize static variables in C++ class?
body: <p>I have noticed that some of my functions in a class are actually not accessing the object, so I made them <code>static</code>. Then the compiler told me that all variables they access must also be static – well, quite understandable so far. I have a bunch of string variables such as</p>
  
  <pre><code>string RE_ANY = "([^\\n]*)";
  string RE_ANY_RELUCTANT = "([^\\n]*?)";
  </code></pre>
  
  <p>and so on in the class. I have then made them all <code>static const</code> because they never change. However, my program only compiles if I move them out of the class: Otherwise, MSVC++2010 complains "Only static constant integral variables may be initialized within a class".</p>
  
  <p>Well that's unfortunate. Is there a workaround? I would like to leave them inside the class they belong to.</p>