To use a constant integer with the if condition I am using this logic in c++ code which compile with the g++ but not with root compiler.
#include <iostream>
using namespace std;
int main() {
int wafer = 26;
int nof1;
if (wafer == 26)
{
nof1 = 25;
}
if (wafer == 10)
{
nof1 = 40;
}
const int nof = nof1;
int array[nof] = {0};
return 0;
}
In the root compilation I am getting this error, /home/sawan/FoCal_India/position_scan_pi/check.cxx:18:16: error: variable-sized object may not be initialized
int array[nof] = {0};
^~~
I have many arrays, histograms and graphs in to code whose size will be given by nof. So does this method works for histograms also? Like TH1F *histograms[nof];
For arrays, I am only filling the array at certain position and rest of the position I need to fill it with zero. This is why I was initializing them with 0;