static const int pointer array(or static array of pointers) in class,help

ok so my c++ is a little rusty, and im trying to do something new here and that is making a class that needs to have a constant static character pointer array. now i need help on how to intialise this array, my class is something like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class abc{
private:
...
static const int *ptrarr[5];
...
};

//want to initialize this constant static array of pointers here.what im trying is something like this. i know the syntax is wrong(which is why im asking this questions) but it should give an idea of what i am trying to do.

const int abc::ptrarr[0]=new int [2];
const int abc::ptrarr[0][0]=3;
const int abc::ptrarr[0][1]=5;
const int abc::ptrarr[0][2]=7;

....





thanks in advance. any help will be appreciated.. and believe it or not, if been trying to figure this out for an hour now :/...
Hello,
well, I tried do this thing you're trying to do but wasnt able to do that but..
Do u really need 2 dimensional array? if one would be enough there is simple way do do this:
1
2
3
4
5
class Object
{
	const static int staticIntArray[] 
};
const int Object::staticIntArray[] = {0,1,2,3};

if u really need a two dimensional array this initizalitation works for me but i there's problem - i am unable to put any values into the array >_<
1
2
3
4
5
class Object
{
	const static int *staticIntArray[];
};
const int *Object::staticIntArray[] = {new int[1],new int[3]};
This works for me:
1
2
3
4
5
6
class Test
{
private:
static const int arr2d[2][3];
};
const int Test::arr2d[2][3]{{1,2,3},{4,5,6}};


- but really, unless you have a very compelling reason to use a 2D array, use a 1D one. Or better yet, just use a vector.
Topic archived. No new replies allowed.