PDA

View Full Version : delete operator (C++)


BWiz
01-23-2010, 08:08 PM
Hi Guys,

I'm working on a linked list for one of my projects, and I just had a quick question about my dequeue function:


void LinkedList<E>::dequeue() {
node<E>* pointer = this->firstObject;
this->firstObject = this->firstObject->next;
delete pointer;
}


Using the above lines of code, I will actually remove (what was) the first item in the queue from the memory, freeing up space right?

Thanks in advice,
BWiz.

oracleguy
01-23-2010, 08:56 PM
Yes.

FYI:
What platform is this on? If you are using the Microsoft's C++ compiler & runtimes there are memory leak checks you can turn on. If you are using the GNU stuff, valgrind can do the same thing (if not more).