Question: I'm getting errors that say no suitable constructor exists to convert from const char [21] to DequeEmpty THIS IS THE CPP FILE #include #include #include
I'm getting errors that say "no suitable constructor exists to convert from "const char [21]" to "DequeEmpty""
THIS IS THE CPP FILE
#include
#include
#include
#include
#include "LinkedDeque.hpp"
#include "DLinkedList.hpp"
#include "DLinkedList.cpp"
LinkedDeque::LinkedDeque()// constructor
: D(), n(0) { }
int LinkedDeque::size() const// number of items in the queue
{ return n; }
bool LinkedDeque::empty() const// is the queue empty?
{ return n == 0; }
// get the front element
const Elem& LinkedDeque::front() const throw(DequeEmpty) {
if (empty())
throw DequeEmpty("front of empty Deque");
return D.front();// linkedlist front is queue front
}
// insert new first element
void LinkedDeque::insertFront(const Elem& e) {
D.addFront(e);
n++;
}
// insert new last element
void LinkedDeque::insertBack(const Elem& e) {
D.addBack(e);
n++;
}
// remove first element
void LinkedDeque::removeFront() throw(DequeEmpty) {
if (empty())
throw DequeEmpty("removeFront of empty deque");
D.removeFront();
n--;
}
// remove last element
void LinkedDeque::removeBack() throw(DequeEmpty) {
if (empty())
throw DequeEmpty("removeBack of empty deque");
D.removeBack();
n--;
}
THIS IS THE HEADER FILE
#ifndef LINKEDDEQUE_H
#define LINKEDDEQUE_H
#include
#include "DLinkedList.hpp"
#include "DLinkedList.cpp"
class DequeEmpty
{
public:
std::string what()
{
return "MyException happened";
}
};
typedef std::string Elem; // deque element type
class LinkedDeque
{ // deque as doubly linked list
public:
LinkedDeque(); // constructor
int size() const; // number of items in the deque
bool empty() const; // is the deque empty?
const Elem& front() const throw(DequeEmpty); // first element
const Elem& back() const throw(DequeEmpty); // last element
void insertFront(const Elem& e); // insert new first element
void insertBack(const Elem& e); // insert new last element
void removeFront() throw(DequeEmpty); // remove first element
void removeBack() throw(DequeEmpty); // remove last element
private:
DLinkedList D; // doubly linked list of elements
int n; // number of elements
};
#endif
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
