I had an assignment just like this last week so allow me to weigh in. First I think you are making this more complicated than it needs to be by having to separate template classes for the node and the list. I just used a struct for the nodes and had it all in one class. Anyway, I skimmed through your code and nothing stuck out at me for being wrong(linked lists can be a pain in this way). I would start by making a method that prints out the entire list then do this to debug
1 2 3 4 5
for (int i = 0; i < 10; i++) {
tempQ->push(i);
tempQ->print();
}
Print the queue each time you add a number, you should see the list grow as you add. If the output doesn't look like it should, then the issue is likely in the push method.
Once that works try this
1 2 3 4 5
for (int i = 1; i < 11; i++) {
int test = tempQ->front();
TempQ->Print();
cout << "popped value: " << test << "\n";
}
Again print each time you change the list, it should be shrinking this time, if not check the pop method.
I tried to first implement this using a template struct but was getting weird errors. How would you go about creating such a struct that could hold a template value as well as a 'next' pointer to the trailing item?
private:
//nodes of the list
struct node
{
type data; //the item in the list
node* next; //next pointer
};
int size; //current size of list
node* head; //points to front of the list
node* tail; //points to the back of the list
Like this, you shouldn't need a template struct, just your queue class should be a template.