So, I want to create an array as a class member variable using the size I get from some other class function.
The following code is within one of my header files
static const int arraySize = B::getInstance().getArraySize();
A* myArray[arraySize];
On trying to run this code, I get the following error: 'In-class initializer for static data member is not a constant expression'
Note: I am trying to do this with just regular arrays (if possible) instead of using something like vectors
Additional Details:
B
is a singleton class with the following method,
const B& B::getInstance() {
static B instance;
return instance;
}
- Signature of
getArraySize()
in classB
is
const int B::getArraySize() const