I'm trying to make a priority queue implementation in C++. I have created a header file called 'priority_queue.h' which contains the definition of my class, alongside a template defining a generic type. I also have a file where I implement my method defined in the class definition in a file called 'priority_queue.cpp' where I include 'priority_queue.h'. Both my text editor and compiler are throwing errors, although they seem to be different.
I've looked up other questions on StackOverflow and other sites, I've even straight up copy-pasted some code from online answers that were supposedly correct and even those didn't work.
Here is the code in my 'priority_queue.h' header file
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
template <typename T>
class pqueue{
public:
pqueue();
void insert(T element, int priority);
private:
vector<T> elements(); //This vector will store our data in the correct order
};
Here is the code from my 'priority_queue.cpp' file
#include <iostream>
#include <iterator>
#include <vector>
#include "priority_queue.h"
using namespace std;
template <typename T>
void pqueue::insert(T element, int priority){
}
The compiler throws an error and says 'template<class T> class pqueue' used without template parameters
.
My text editor gives me an error that says name followed by '::' must be a class or namespace name
I'm on a Dell XPS 13 9370 with the i7 8550U, 16GB of RAM and 256GB SSD running Windows 10 Home Version 1903 and my text editor is Microsoft Visual Studio Code Insiders.