Deleting a dynamic array of std::lists

Started by
2 comments, last by Kyle N 20 years, 5 months ago
Hi guys, Small problem, this may be a stupid question - rough hangover , if I create a dynamic array where each element is a std::list as such: std::list *pFreeList = new std::list[10]; How do I delete each std::list element of the array? Thanks Kyle
Advertisement
When deleting your array, just cycle through it and clear each list explicitly before deleting the array elements with delete [], should work.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
delete [] pFreeList;
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
D''oh..! Thought it was something std::list specific that wouldn''t allow delete[] to work, turns out it was a typo..! Took long enough to spot :/

Thanks guys
Kyle

This topic is closed to new replies.

Advertisement