#include <stdio.h>
class test
{
public:
test()
{
sample = 1;
}
private:
int sample;
int *array[sample];
};
int main()
{
test a;
return 1;
}
The variable sample = 1 is to be assigned to the array of pointers *array[sample]. But when I compile, I get the following error:
test1.cpp:10: error: invalid use of non-static data member âtest::sampleâ
test1.cpp:11: error: from this location
test1.cpp:11: error: array bound is not an integer constant
Actually, I wanna to create an array of pointers with size of a variable which is passed from the constructor. In this case, sample is the varaible passed from constructor and *array[sample] is the array of pointers.
The above code is just stimulation of my actual problem.