Implement a Class Template Queue data structure for queue operations such as Full() and Empty() with exception handling. Note: Use templates with exception handling and size of queue is set to 5.
Print: "An queue overflow exception occurred!" or "An queue empty exception
#include <iostream>
using namespace std;
template<class T>
class Queue
{
public:
Queue();
bool isEmpty();
void enqueue(T data);
void dequeue();
private:
struct Node{
T date;
Node *next;
};
Node *frontPtr;
Node *backPtr;
static int count;
};
int main()
{
Queue<int> q;
return 0;
}
template<class T>
Queue<T>::Queue()
{
count = 5;
if(count >= 5)
{
try
{
throw "The queue is full!";
} catch(string &e)
{
cout << e;
}
}
frontPtr = nullptr;
backPtr = nullptr;
}
template<class T>
bool Queue<T>::isEmpty(){
return(count == 0);
}
Comments
Leave a comment