Why don't you use templates ?
----
template <class T>
class LNode
{
public:
LNode(T pData,LNode *pNext):data(pData),next(pNext){}
T data;
LNode *next;
};
template <class T>
class LList
{
protected:
LNode<T> *head;
LNode<T> *tail;
public:
LList()
{
head=tail=NULL;
}

void push_back(T pData)
{
if(head==NULL)
{
head=tail=new LNode<T>(pData,NULL);
return;
}
tail->next=new LNode<T>(pData,NULL);
tail=tail->next;
}
void push_front(T pData)
{
if(head==NULL)
{
head=tail=new LNode<T>(pData,NULL);
return;
}
LNode<T> *nnode=new LNode<T>(pData,head);
head=nnode;
}
void Print()
{
LNode<int> *cur=head;
while(cur)
{
cout<<cur->data<<',';
cur=cur->next;
}
cout << endl;
}
void Reverse()
{
LNode<T> *cur=head;
LNode<T> *prev=NULL;
LNode<T> *tmp;
while(cur)
{
tmp=cur->next;
cur->next=prev;
prev=cur;
cur=tmp;
}
tmp=head;
head=prev;
tail=tmp;
}
};

Regards

On Thu, May 31, 2012 at 8:49 AM, mahendra sengar <sengar.m...@gmail.com>wrote:

> how to implement generioc linked list..using void pointer...i havent
> used void pointer much so, m not able to use it properly in linked
> list..please help asap !!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to