title: c++ initialize class member variable depends on other member variable
body: <p>Basically, a non-static member <code>theta</code> which initialize by another class member but well initialized. Then <code>valley_max</code> initialized by <code>theta</code> as you can see. Right now everything works fine. Then I want to initialize a array whose bound is <code>valley_max</code>. First, the I got error :</p>
  
  <blockquote>
    <p>invalid use of non-static data member   </p>
  </blockquote>
  
  <p>Then I add <code>static const int valley_max</code> as you can see. But I got error like:</p>
  
  <blockquote>
    <p>array bound is not an integer constant before ']' token</p>
  </blockquote>
  
  <p>I just wondering if I can initialize the array whose bound initialized by a member variable which initialized by another member variables.<br>
  Thanks for your help.</p>
  
  <p><strong>AP_Tmxk_VFH.cpp</strong></p>
  
  <pre><code>AP_Tmxk_VFH::AP_Tmxk_VFH() :
      l(5),
      threshold(5),
      safe_space(0.7),
      detected_range(2.5),
      theta(degrees(acos(1-sq(safe_space)/(2*sq(detected_range))))),
      valley_max(round_float(180.0/theta)),
      valley_count(0),
  {
  }
  </code></pre>
  
  <p><strong>AP_Tmxk_VFH.h</strong></p>
  
  <pre><code>class AP_Tmxk_VFH {
  privte:
         int l;
         int threshold;
         int safe_space;
         int theta;
         int detected_range;
         static const int valley_max ;
         struct{
  
           bool inside_valley  = false;
           uint16_t up_bound   = 0;  
           uint16_t down_bound = 0; 
     }valley[valley_max];
  }
  </code></pre>