Basically, a non-static member theta
which initialize by another class member but well initialized. Then valley_max
initialized by theta
as you can see. Right now everything works fine. Then I want to initialize a array whose bound is valley_max
. First, the I got error :
invalid use of non-static data member
Then I add static const int valley_max
as you can see. But I got error like:
array bound is not an integer constant before ']' token
I just wondering if I can initialize the array whose bound initialized by a member variable which initialized by another member variables.
Thanks for your help.
AP_Tmxk_VFH.cpp
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),
{
}
AP_Tmxk_VFH.h
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];
}