709394
04-19-2003, 08:14 PM
I try to create a link list that hold at each of its node another link list using template. But it doesn't work and I found out that template class can't be used as a template-type. Does someone know a workaround?
To demonstrate what I mean, here is the empty code :
This code doesn't work but this is what I want to do.
#include <iostream.h>
template <class T>
class LinkList
{
public:
LinkList(){};
};
int main(void)
{
LinkList<LinkList> LL;
return 0;
}
Code that works without using template class as template-type.
#include <iostream.h>
template <class T>
class LinkList
{
public:
LinkList(){};
};
class LinkListNotemplate // EXACTLY the same implemention of LinkList class above.
{
public:
LinkListNotemplate(){};
};
int main(void)
{
LinkList<LinkListNotemplate> LL;
return 0;
}
If I HAVE TO CODE the second way, then what is the POINT of template then?
To demonstrate what I mean, here is the empty code :
This code doesn't work but this is what I want to do.
#include <iostream.h>
template <class T>
class LinkList
{
public:
LinkList(){};
};
int main(void)
{
LinkList<LinkList> LL;
return 0;
}
Code that works without using template class as template-type.
#include <iostream.h>
template <class T>
class LinkList
{
public:
LinkList(){};
};
class LinkListNotemplate // EXACTLY the same implemention of LinkList class above.
{
public:
LinkListNotemplate(){};
};
int main(void)
{
LinkList<LinkListNotemplate> LL;
return 0;
}
If I HAVE TO CODE the second way, then what is the POINT of template then?