#include <iostream>
#include <iomanip>
usingnamespace std;
class PCB
{
public:
int PID;
string fileName;
};
template<class T>
class myQueue
{
protected:
class Node
{
public:
T info;
Node *next;
Node *prev;
};
Node *head;
Node *tail;
int count;
public:
void getHead(Node **tempHead);
};
template<class T>
void myQueue<T>::getHead(Node **tempHead)
{
*tempHead = head;
}
#endif
my main is :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include "myQueue.h"
#include <iostream>
int main()
{
myQueue<PCB> queue;
//How can I access the Head pointer of my Queue here?
//queue.getHead(&tempHead);
return 0;
}
Dear JLBorges, thank you very much. Yup, you are right, it is violation and I should use deque. However, your code make me learn something new. Thanks again and have a nice weekend.
There are some types of queues in c++ and they are very recommended to use. Making your own one can lead to some errors that had already been fixed in the built in ones (within the std library). Of course you can use your just watch out from errors. If you need help with those kind of errors you can get some programs to help you, such as checkmarx or others, to detect errors.
Good luck!
Ben.