pointers - Array of credentials -


i'm developing credential provider , credential. have class sampleprovider , samplecredential. works when declare sampleprovider has one, or two, or constant number of samplecredential, declaring:

samplecredential * _pcredential[2] 

but now, want dynamically allocated. have this:

samplecredential * *_pcredential 

and inside method setusagescenario(), code read number of credentials txt file, , allocate it:

(*_pcredential) = new samplecredential[numbercount]; 

but not working. keep getting error on line. says

access violation writing location 0x00000000 ;

do know happens here , do?

_pcredential has not been initialized yet , still null. attempting dereference null pointer via "(*_pcredential)" result in access violation.

maybe meant this?

_pcredential = new samplecredential*[numbercount]; 

that allocate array of pointers samplecredential objects. can allocate each samplecredential object this:

_pcredential[0] = new samplecredential(); // etc. 

remember free memory when you're done:

for (int = 0; < numbercount; i++) {     delete _pcredential[i]; } delete [] _pcredential; 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -