Here is the error I am receiving and need help resolving...
g++ -g -c -std=c++11 main.cpp
In file included from main.cpp:3:0:
Executive.h:18:25: error: cannot declare field 'Executive::queue' to be of abstract type 'ListQueue<std::basic_string<char> >'
ListQueue<std::string> queue;
^
In file included from Executive.h:12:0,
from main.cpp:3:
ListQueue.h:8:7: note: because the following virtual functions are pure within 'ListQueue<std::basic_string<char> >':
class ListQueue : public QueueInterface<ItemType>
^
I'm not used to using "virtual" classes or even C++ for that matter, still learning, but I'm having trouble compiling my code as it is now. The virtual classes were provided by the instructor, so I'm just going to post the header files for my Executive, ListQueue, and ArrayStack classes. ListQueue and ArrayStack are the classes related to their "virtual" QueueInterface and StackInterface classes.
Executive.h
#include <iostream>
#include <string>
#include <fstream>
#include "ListQueue.h"
#include "ArrayStack.h"
class Executive
{
private:
ListQueue<std::string> queue;
ArrayStack<std::string> stack;
std::string serving = "no one";
std::string waiting = "no one";
bool isWaiting = false;
bool wasVIP = false;
bool servingVIP = false;
public:
/** Constructor reads in input file */
Executive(std::istream& inputFile);
/** Reads in and interprets the text file */
void read(std::istream& is);
/** Shows that the person currently being served finishes and the person waiting begins */
void done();
/** Shows who is currently being served and who is next */
void show();
};
ListQueue.h
#include "QueueInterface.h"
#include "Node.h"
template<class ItemType>
class ListQueue : public QueueInterface<ItemType>
{
private:
Node<ItemType>* first; //front of queue
Node<ItemType>* last; //end of queue
public:
ListQueue(); // Default constructor
bool isEmpty() const = 0;
void enqueue(const ItemType& newEntry) throw (PrecondViolatedExcep) = 0;
void dequeue() throw (PrecondViolatedExcep) = 0;
ItemType peekFront() const throw (PrecondViolatedExcep) = 0;
}; // end ListQueue
ArrayStack.h
#include "StackInterface.h"
const int MAX_STACK = 10;
template<class ItemType>
class ArrayStack : public StackInterface<ItemType>
{
private:
ItemType items[MAX_STACK]; // Array of stack items
int top; // Index to top of stack
public:
ArrayStack(); // Default constructor
bool isEmpty() const;
void push(const ItemType& newEntry) throw (PrecondViolatedExcep);
void pop() throw (PrecondViolatedExcep);
ItemType peek() const throw (PrecondViolatedExcep);
}; // end ArrayStack
StackInterface
template<typename ItemType>
class StackInterface
{
public:
/** Sees whether this stack is empty.
@return True if the stack is empty, or false if not. */
virtual bool isEmpty() const = 0;
/** Adds a new entry to the top of this stack.
@pre a push is possible
@post If the operation was successful, newEntry is at the top of the stack.
@param newEntry The object to be added as a new entry. */
virtual void push(const ItemType& newEntry)
throw (PrecondViolatedExcep) = 0;
/** Removes the top of this stack.
@pre The stack is not empty.
@post If the operation was successful, the top of the stack
has been removed. */
virtual void pop()
throw (PrecondViolatedExcep) = 0;
/** Returns the top of this stack.
@pre The stack is not empty.
@post The top of the stack has been returned, and
the stack is unchanged.
@return The top of the stack. */
virtual ItemType peek() const throw (PrecondViolatedExcep) = 0;
}; // end StackInterface
QueueInterface
template<typename ItemType>
class QueueInterface
{
public:
/** Sees whether this queue is empty.
@return True if the queue is empty, or false if not. */
virtual bool isEmpty() const = 0;
/** Adds a new entry to the back of this queue.
@pre an enqueue is possible
@post If the operation was successful, newEntry is at the
back of the queue.
@param newEntry The object to be added as a new entry. */
virtual void enqueue(const ItemType& newEntry)
throw (PrecondViolatedExcep) = 0;
/** Removes the front of this queue.
@pre The queue is not empty.
@post If the operation was successful, the front of the queue
has been removed. */
virtual void dequeue()
throw (PrecondViolatedExcep) = 0;
/** Returns the front of this queue.
@pre The queue is not empty.
@post The front of the queue has been returned, and the
queue is unchanged.
@return The front of the queue. */
virtual ItemType peekFront() const
throw (PrecondViolatedExcep) = 0;
}; // end QueueInterface