Hi all,
I created a Queue<T> class in c++,
when I call the destructor and trying to delete the array I get the error:
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
this is a short of my code:
calling it from the main:
I know that there are lots of questions about this error, but I simply couldn't make mine to work.
I'd really appreciate your comments!
Thanks,
Tal
I created a Queue<T> class in c++,
when I call the destructor and trying to delete the array I get the error:
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
this is a short of my code:
template <class T> class Queue { private: int head, tail, size, max; T *arr; static int count; public: Queue(int max=10); Queue(const Queue &q); ~Queue(); static void init(); static void print_count(); bool isEmpty(); bool isFull(); bool enQueue(T value); bool deQueue(T *pValue); Queue merge(Queue<T> q1, Queue<T> q2); }; template<class T> Queue<T>::Queue(int max = 10) { this->max = max; size = 0; head = 0; tail = 0; count++; arr = new T[max]; } template<class T> Queue<T>::Queue(const Queue &q) { max = q.max; size = q.size; head = q.head; tail = q.tail; count++; arr = new T[max]; for(int i =0; i < size; i++) { arr[(head + i) & max] = q.arr[(head + i) % max]; } } template<class T> Queue<T>::~Queue() { count--; delete[] arr; }
calling it from the main:
Queue<int> q1; q1.~Queue();
I know that there are lots of questions about this error, but I simply couldn't make mine to work.
I'd really appreciate your comments!
Thanks,
Tal