title: how to initialize a non-static const variable in class in C++?
body: <p>I wrote these following codes in Stack.h:</p>
  
  <pre><code>class Stack{
  public:
      inline bool full();
      int size();
      inline bool empty();
      bool push(const string&amp;);
      bool pop(string &amp;s);
      bool peek(string &amp;s);
      virtual void print();
      virtual ~Stack(){}
  
  protected:
      vector&lt;string&gt; _elem;
      int const _maxsize=10;    // line X
  };
  </code></pre>
  
  <p>I got the error:</p>
  
  <pre><code>Stack.h:14: error: ISO C++ forbids initialization of member ‘_maxsize’
  Stack.h:14: error: making ‘_maxsize’ static
  make: *** [Stack.o] Error 1
  </code></pre>
  
  <p>if I add a static keyword at line X, and initialize the variable outside the class definition, it could be OK.</p>
  
  <p><strong>But my question is that is there any possible way to declare a non-static const variable and still successfully initialize it???</strong></p>