R
Rahul Joshi
Hi,
I want to create a static array whose size is also a const
member of the class. Something like:
// A.h
class A {
private:
static int size = 0;
static int array[size];
};
Then I need to define the static array in A.cpp like:
int A::array[A::size];
However, the compiler complains that A::size is a private
and cannot be accessed. So how can I define such a static
array without making the size of the array public ?
Thanks,
Rahul
I want to create a static array whose size is also a const
member of the class. Something like:
// A.h
class A {
private:
static int size = 0;
static int array[size];
};
Then I need to define the static array in A.cpp like:
int A::array[A::size];
However, the compiler complains that A::size is a private
and cannot be accessed. So how can I define such a static
array without making the size of the array public ?
Thanks,
Rahul