Hello list,
I've got a class defined, with a template, to create a sort of container.
I'm using a pointer to hold the top element of the container, and with that 
pointer, I can enlarge or shrink the container with new.
Now, I've got an add function that works great. What I need to get going, is 
the remove command.
My theory is this:
If I have 20 elements, and it's 0 based, I can remove say element 5, then I 
would have an empty spot.
So, with that empty spot, I could shrink the array, by taking element 6, and 
setting 5 equal to that, 7=6 8=7, etc, until I'm finally left with a blank 
element at the end, which I could dispose of, by resizing the array and 
shrinking it to the number of elements in the code.
apparently this isn't working to well.
Here's the code; I'm getting an access violation.
//code:
BOOL Remove(int elem) {

if (elem<0||elem>this->size)

return false;

//now we do the fun thing, and decompress the container, and then delete 1 
element from the bottom.

int i=0;

for(int counter=++elem;counter++;counter<this->size) {

i=counter--;

top[i]=top[counter];

}

--this->size;

this->top=new T[this->size];

return true;

}

//end code:
Thanks for all the help, and feedback is appriciated.
Thanks,
~~TheCreator~~
Visit TDS for quality software and website production
http://tysdomain.com
msn: [EMAIL PROTECTED]
skype: st8amnd127

[Non-text portions of this message have been removed]

Reply via email to