how to return pointer to class from function with class with template ?
I tries to do so, but not working:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
template <class T> linkP<T>* list<T>::chkSubString(const list<T> &_ls)
{
linkP<T> *p2=_ls.last, *p3, *tmp;
int mone1=0, mone2=0;
for(linkP<T> *p=_ls.last; p!=NULL; p=p->prev, mone1++);
//cout<<mone1;
for(linkP<T> *p1=last; p1!=NULL && p2!=NULL; p1=p1->prev)
{
p3=p1;
p2=_ls.last;
tmp=p1;
mone2=0;
while (p1!=NULL && p2!=NULL && p1->value==p2->value)
{
//cout<<"p1: "<<p1->value<<" ";
//cout<<"p2: "<<p2->value<<" ";
mone2++;
p1=p1->prev;
p2=p2->prev;
}
p1=p3;
if (mone1==mone2)
{
cout<<"true";
return tmp;
}
}
cout<<"false\n";
return tmp;
}
|
Last edited on
Could you be more presize what is not working?