New and delete operator with queues

Im trying to write my own code for a queue and will be using the new and delete commands but i want to be sure this code wont have memory leaks or other problems.
Its a simple class for queues and the size of the queue is known at compile time, so this shouldnt be a problem.
Its my first time using new, delete and templates, so suggestions would be greatly helpful.

template <typename T>
class Queue {
public:

	Queue(uint16_t size);
	~Queue();

	T deQueue();
	bool enQueue(T in);

	bool isEmpty() { return numElements == 0 ? true : false; };
	bool isFull() { return numElements == size ? true : false; };
	T rear() { return queue[head == 0 ? (size - 1) : (head - 1)]; };
	T front() { return queue[tail]; };


private:

	T *queue;

	uint16_t head = 0;
	uint16_t tail = 0;

	uint16_t size;

	uint16_t numElements = 0;

};




template <typename T>
Queue<T>::Queue(uint16_t _size) {

	size = _size;

	queue = new T[size];

}


template <typename T>
Queue<T>::~Queue() {

	delete [] queue;

}


template <typename T>
T Queue<T>::deQueue() {

	T obj = NULL;

	if (numElements == 0) return obj;

	obj = queue[tail];

	tail++;
	numElements--;

	if (tail >= size) tail = 0;

	return obj;

}


template <typename T>
bool Queue<T>::enQueue(T in) {

	if (numElements == size) return false;

	queue[head] = in;

	head++;
	numElements++;
	if (head == size) head = 0;

	return true;

}

Is this an academic exercise? I'm pretty sure the STL has queues.

What Arduino are you using?

If it is an Uno or Mega (or similar) I suggest you allocate the memory needed for the biggest queue(s) at compile time as memory manipulation in the small memory of an Arduino can easily result in a crash.

You would have more room for manoeuvre in an ESP8266 or ESP32 but even then I would be wary of the possibilities of writing on memory you don't own when there is no operating system to protect you.

...R

What is "the STL"?

-jim lee

C++ Standard Template Library

Since your Queue class contains a pointer to a dynamically allocated array of objects, you should probably either delete 'copy constructor' and '&operator=' functionality or properly implement them. Otherwise, the default implementation of these operations will simply copy the pointer, thus leaving you with multiple objects pointing to the same dynamically allocated array.