Initialization of static array

Hi, how should i do initialization for static array

in H file i have

static IVTEntry *entries[16];

and in CPP file i should have something like this

IVTEntry IVTEntry::entries=new IVTEntry[16];

but i get error " Type mismatch in redeclaration of 'IVTEntry::entries' " ??

Thx
Last edited on
1
2
3
4
static IVTEntry *entries[16]; //an array of 16 pointers

IVTEntry IVTEntry::entries //one object
   =new IVTEntry[16]; //trying to assign it a pointer 


I guess that you want to do
IVTEntry* IVTEntry::entries[16];
In the header you are declaring entries to be an array of pointers to IVTEntry while in the source file you are using a new statement that returns a single pointer to an IVTEntry. The header should be changed to be just a pointer (throw away the array subscript part).
No, i need array of pointers to IVTEntry, how can i set all 16 pointers to NULL at begining

IVTEntry* IVTEntry::entries[16]= ???
In that case using new is incorrect; your array already has all the space allocated to it. You can just use normal array initiliazation here:

IVTEntry IVTEntry::entries = {NULL, NULL, /*etc*/ };
OK, so there is no quicker way, if i have array of 100 i need to write it 100 times?
1
2
3
IVTEntry* IVTEntry::entries[16]; //zero initialized if global
void* foo[42] = {6,9,13}; //zero initialized, the other elements
void* foo[42] = {}; //¿is this standard? (sigh) 
Topic archived. No new replies allowed.