I'm a little stuck. I'm getting a few errors and I'm not quite understanding what I'm doing wrong here. I have my code posted. I'm going to have arrows pointed where I'm getting errors and what it's saying"
#include "memoryleakdetect.h" // this must be the first #include in each of your .cpp files
#include "quack.h"
using namespace std;
// change the value of this variable to be your own name instead of "I. Forgot"
const char Quack::YOUR_NAME[] = "I. Forgot";
Quack::Quack(int capacity)
{
items = new item[capacity]; <-----------c:\users\brian williams\desktop\260\lab2\quake\quake\quack.cpp(14): error C2440: '=' : cannot convert from 'Quack::item *' to 'int *'
backPtr = new item;
frontPtr = new item;
midPtr = new item;
current = new item;
maxSize = capacity;
back = maxSize-1;
count = 0;
top = -1;
}
Quack::~Quack(void)
{
delete frontPtr;
delete backPtr;
delete current;
delete midPtr;
delete [] items; //Heap Corruption Debug Error at the end of program.
items = NULL;
maxSize = 0;
back = 0;
}
bool Quack::pushFront(const int n)
{
int i = 0;
if ( count == maxSize ) // Then we cant add to it n e more.
{
throw runtime_error( "Stack is Full" );// Full Stack
return false;
}
backPtr->n = items[back-1];
while ( i < count ) // Loop less than however many we counted.
{
if ( i == top+1 )
{
current->n = items[top+1];
items[top+1] = backPtr->n;
}
for ( int i = 0; i < count / 2; i++ )
{
items[j] = items[i];
items[i] = items[ count - i-1 ];
items[ count - i-1 ] = items->n; <----------c:\users\brian williams\desktop\260\lab2\quake\quake\quack.cpp(155): error C2227: left of '->n' must point to class/struct/union/generic type
type is 'int *'
}
ostream& operator<<(ostream& out, Quack *q)
{
if ( q.count == 0 ) // No elements have been counted. <---------c:\users\brian williams\desktop\260\lab2\quake\quake\quack.cpp(169): error C2228: left of '.count' must have class/struct/union
type is 'Quack *'
out << endl << "quack: empty" << endl;
else
{
out << endl << "quack: ";
for ( int i = 0; i <
q.count; i++ ) <-----c:\users\brian williams\desktop\260\lab2\quake\quake\quack.cpp(175): error C2228: left of '.count' must have class/struct/union
type is 'Quack *'
{
if ( i < q.count-1 ) <-------c:\users\brian williams\desktop\260\lab2\quake\quake\quack.cpp(175): error C2228: left of '.count' must have class/struct/union
type is 'Quack *'
out << q.items[i] << ", "; <----c:\users\brian williams\desktop\260\lab2\quake\quake\quack.cpp(175): error C2228: left of '.count' must have class/struct/union
type is 'Quack *'
else out << q.items[i]; <------c:\users\brian williams\desktop\260\lab2\quake\quake\quack.cpp(175): error C2228: left of '.count' must have class/struct/union
type is 'Quack *'
}
out << endl << endl;
}
return out;
}
Is there something that I'm missing or I need to fix?