c++ - Access violation error when creating pointer to pointer List -


i,m trying create pointer pointer list

list<objectclass*> *lst_testlist;

and trying use way

void functioningclass::functioningmethod() {     objectclass *object = new objectclass();     object->i_testing = 234;     lst_testlist->push_back(object);     object = lst_testlist->front();     cout<<object->i_testing;     std::getchar(); } 

i can build program. when run it,it gives me error.

unhandled exception @ 0x012885da in consoleapplication7.exe: 0xc0000005: access violation reading location 0x00000004.

notice when create list

list<objectclass*> lst_testlist; 

and use this,

lst_testlist.push_back(object); 

it didn,t give me error.

such list<objectclass*> lst_testlist; variable default-initialized.

for pointer list<objectclass*>* lst_testlist; default initialization not performed. proper initialization is:

list<objectclass*>* lst_testlist = new list<objectclass*>(); 

or

list<objectclass*>* lst_testlist = null; 

it depends on goals.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -