mam taką klase
template <typename T>
class queueTp
{
static const int MAX_QUEUE = 10;
private:
struct node { T item; node * next; };
node * m_front, * m_rear;
int m_rozmiar;
const int m_max_rozmiar;
public:
queueTp();
queueTp(int max_size);
bool isempty(void) const;
bool isfull(void) const;
bool add(T x);
bool remove_first(void);
void show(void);
};
i funkcja add
template <typename T>
bool queueTp<T>::add(T x)
{
if( isfull() )
return false;
node * dodaj = new node;
if(dodaj == NULL)
return false;
dodaj->item = x;
dodaj->next = NULL;
m_rozmiar++;
if(m_front == NULL)
{
m_front = dodaj;
m_rear = dodaj;
}
else
m_rear->next = dodaj;
m_rear = dodaj;
m_rear->next = NULL;
return true;
}
i chciałbym żeby ta klasa mogła być również kolejką wskaźników na dowolny typ np. queueTp<int *>
ale moja funkcja operuje wartościami, a w przypadku wskaźników będą potrzebne adresy
muszę robić osobny szablon dla wskaźników?? czt da się zrobic wszystko w jednym??