My program is supposed to be a self written QUEUE template along with a driver to test out the QUEUE. My QUEUE is working fine and so is my driver. It is able to test everything out perfectly. However, as soon as I put my destructor in the QUEUE template I get the error
malloc: *** error for object 0x100103ad0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
I had a similar issue before but that only occurred when I ran my .h file with my test driver. When I ran it with my app I did not receive that error. However, since I'm solely using my driver to test out my QUEUE template I have to figure out a way to get past this error.
I'm not exactly understanding the error. It's saying that the pointer being freed was not allocated? Shouldn't the pointer be allocated as soon as my program runs by the constructor?
I cannot reproduce your issue.
At least provide a backtrace
Edit: Queue <double> copy = test; calls the copy constructor
1 2
Queue <double> copy;
copy = test;
calls the assignment operator, which you didn't provide code for. So it is using the default one, that makes a shallow copy so you are deleting the same node twice.