![]() |
| | #1 |
| Registered User Join Date: Sep 2006 Location: vancouver wa
Posts: 216
| Heap corruption Detected Error In reference to: delete [] items; I have also tried to comment out the other pointers and it still does it.. Code: #pragma once
#include <ostream>
using namespace std;
class quack
{
public:
quack(int capacity);
~quack(void);
bool pushFront(const int n); // push an item onto the front
bool pushBack(const int n); // push an item onto the back
bool popFront(int& n); // pop an item off the front
bool popBack(int& n); // pop an item off the back
void rotate(int r); // "rotate" the stored items (see note below)
void reverse(void); // reverse the order of the stored items
int itemCount(void); // return the current number of stored items
private:
int front;
int back;
int maxsize;
int count;
struct item // definition of each item stored by the quack
{
int n;
};
item *items; // pointer to storage for the circular array
item *frontPtr;
item *backPtr;
item *reversePtr; // pointer to storage for the circular array
public:
friend ostream& operator<<(ostream& out, quack& q);
friend ostream& operator<<(ostream& out, quack::item& i);
};
Code:
quack::quack(int capacity): maxsize(capacity+1), front(capacity-2), frontPtr(NULL), backPtr(NULL),
back(0), count(0), items( new item[capacity])
{
frontPtr = new item;
backPtr = new item;
reversePtr = new item;
}
quack::~quack(void)
{
delete frontPtr;
delete backPtr;
delete reversePtr;
delete [] items; // causing crash - i have also tried delete items;
}
|
| mrsirpoopsalot is offline | |
| | #2 |
| Registered User Join Date: Sep 2006 Location: vancouver wa
Posts: 216
| Some reason i didnt notice that it didnt upload.. |
| mrsirpoopsalot is offline | |
| | #3 |
| Registered User Join Date: Sep 2006 Location: vancouver wa
Posts: 216
| nevermind i foud the problem maxsize(capacity+1) Sorry |
| mrsirpoopsalot is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Quantum Random Bit Generator | shawnt | C++ Programming | 62 | 06-18-2008 10:17 AM |
| Making C DLL using MSVC++ 2005 | chico1st | C Programming | 26 | 05-28-2008 01:17 PM |
| Post... | maxorator | C++ Programming | 12 | 10-11-2005 08:39 AM |
| Why wont my function exit correctly? | LightsOut06 | C Programming | 2 | 10-09-2005 09:23 PM |
| Please Help - Problem with Compilers | toonlover | C++ Programming | 5 | 07-23-2005 10:03 AM |