0

please help It says when creating the object of ArrayCharQueue that I can't because it is abstract and am not understanding why please help

//array based charqueue
// must use abstract base class char queue
// must be dynamically allocated

#include "charqueue.h"
#include <iostream>
#include <cstdlib>

class ArrayCharQueue : public CharQueue
{
 public:
  ArrayCharQueue();// constructor
  //copy constructor
  ArrayCharQueue(ArrayCharQueue& souce);
  //destructor
  virtual ~ArrayCharQueue();
 // Methods
  bool isEmpty() ;
  void enqueue(const char newItem);
  char dequeue(void);
  char getFront(void);
 private:
  int arraySize;
  char *array;
  int front;
  int back;

};
// end class ArrayCharQueue()
//end of header


#include "arraycharqueue.h"

using namespace std;

//constructors
ArrayCharQueue::ArrayCharQueue()
{
  front = 0;
  back = 0;
  //count = 0;
  arraySize = 0;
  array = new char[arraySize];
}//end default constructor
ArrayCharQueue::ArrayCharQueue(ArrayCharQueue& souce)
{
	
}
ArrayCharQueue::~ArrayCharQueue()
{
	
}


//methods
bool ArrayCharQueue::isEmpty()
{
  return arraySize  == 0;
}

void ArrayCharQueue::enqueue(const char newItem)
{
  arraySize = arraySize+1;
  char *temp = array;
  array = new char[arraySize];
  for(int i =0;i<arraySize-1;i++)
    {
      array[i] = temp[i];
    }
  delete [] temp;
  array[arraySize-1] = newItem;
  back = arraySize-1;
}
char ArrayCharQueue::dequeue(void)
{
  if(isEmpty())
    {
      cout << "Error Array is Empty\n";
      exit(1);
    }
  char *temp = array;
  char data = array[front];
  arraySize = arraySize-1;
  array = new char[arraySize];
  for(int i=0;i<arraySize;i++)
  {
	  array[i] = temp[i+1];
  }
  delete []temp;
  back = arraySize-1;
  return data;
}
char ArrayCharQueue::getFront()
{
	return array[front];
}

again thanks for any help

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by mike_2000_17
0

You must show the declaration of CharQueue in order to find the mistake. For ArrayCharQueue class to be abstract, it means that the CharQueue is abstract (has a pure method ("= 0;") that is not implemented in the ArrayCharQueue class).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.