title: Why can't I use static members inside class in c++?
body: <pre><code>using namespace std;
  class test{
      private:
      int a,b;
      public:
      static int count=0;
      test(int a=10,int b=10){
          count++;
      }
  };
  int main(){
      test t;
      cout&lt;&lt;t.count&lt;&lt;endl;
      test t1;
      cout&lt;&lt;t1.count&lt;&lt;endl;
  
  }
  </code></pre>
  <p>I have used static member which is initialized inside the class, I have tried outside the class it works fine, but I don't get how is that a error in first place which is initializing the member inside class.</p>
  <p>When I run the above code it gives me the following error:
  <strong>ISO C++ forbids in-class initialization of non-const static member 'test::count'.</strong></p>
  <p>Why I cant initialize a static member inside class?</p>