title: Setting value to an static const unsigned int
body: <p>I have a class that has a static constant unsigned int variable. I want to initialize this variable depending on the arguments passed when the program starts. I have created an example of what I want to do to try and figure out how to implement this.</p>
  
  <p>main.cpp</p>
  
  <pre><code>int main() {
      const unsigned int legs = 4;
      Dog dog(legs);
      return 0;
  }
  </code></pre>
  
  <p>Dog.h</p>
  
  <pre><code>class Dog {
  public:
      Dog(const unsigned int legs);
      ~Dog();
  private:
      static const unsigned int legs;
  };
  </code></pre>
  
  <p>Dog.cpp</p>
  
  <pre><code>Dog::Dog(const unsigned int l) : legs(l) {
  
  }
  
  Dog::~Dog() {
  
  }
  </code></pre>
  
  <p>In main, I created a variable to simulate the value being passed from the program when it runs.</p>
  
  <p>The compiler gives the following errors:</p>
  
  <pre><code>/home/jota/ClionProjects/Caca/Dog.cpp: In constructor ‘Dog::Dog(unsigned int)’:
  /home/jota/ClionProjects/Caca/Dog.cpp:7:34: error: ‘const unsigned int Dog::legs’ is a static data member; it can only be initialized at its definition
   Dog::Dog(const unsigned int l) : legs(l) {
                                    ^
  make[2]: *** [CMakeFiles/Caca.dir/Dog.cpp.o] Error 1
  make[1]: *** [CMakeFiles/Caca.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>I have been looking on the internet and a saw a few examples of a static const int working the way I used it, or I might be missing something. I'm compiling with <code>-std=c++11</code>. </p>