Problem with pointer array

Hello

i have a problem with an pointer array

List **l = new List[5];

after i made the array of pointer to point to some values i want to remove one of the values that i point to, i dont really know how to do this i tried to make a for loop:

1
2
3
4
5
6
7
for(int i = 0; i < size ; i++)
{
   if(l[i]->getValue() == enteredValue)
   {
      delete l[i];
   }
}


when i do this it gives me error next time im in the loop, it says something that it can't read the memory location

any suggestions?
List **l = new List[5]; <--- this shouldn't even compile

You probably meant to do this:

 
List** l = new List*[5];  // make 5 pointers, not 5 Lists 


But of course those 5 pointers don't do anything unless they actually point to something.... so maybe you meant to do this?:

 
List* l = new List[5];

Topic archived. No new replies allowed.