I have some arrays that I need to initialize and use repeatedly throughout a class. For example:
For the appropriate scope I need to declare the pointer to the array in the interface. However, if I declare cubeMaterialDiffusion in the interface as:
then I know of no concise way to initialize the array. I could do:
Is there a better way to do this?
Code:
float cubeMaterialDiffusion[] = {0.3, 0.7, 0.3, 1.0};
For the appropriate scope I need to declare the pointer to the array in the interface. However, if I declare cubeMaterialDiffusion in the interface as:
Code:
float* cubeMaterialDiffusion;
then I know of no concise way to initialize the array. I could do:
Code:
cubeMaterialDiffusion = malloc(4*sizeof(float));
cubeMaterialDiffusion[0] = 0.3;
cubeMaterialDiffusion[1] = 0.7;
cubeMaterialDiffusion[2] = 0.3;
cubeMaterialDiffusion[3] = 1.0;
Is there a better way to do this?