c++ - Declaring an array with constant size - compilation error -
can me explain this:
i declare constant in headerfile:
const int incrsize;
then in mil constant initialized:
: incrsize(10)
then later on in function in code (its callback-function used in gtkmm-gui
bool mywindow::on_drawing_expose_event(gdkeventexpose* event)
i allocate array on stack using constant
double arrpxstep[incrsize];
when compiling following errors:
-expected constant expression - cannot allocate array if constant size 0 - arrpxstep unknown size
i know constant initialzed - how come array cannot use constant memeber-variable alreade initialized in mil?
by looks of code post, incrsize non-static member of class. can't use initialize array, if value set same in constructor. it's rules.
make incrsize static const member, defined within class, , work.
Comments
Post a Comment