结构体:
struct NodeInt{
int num;
struct NodeInt * next;
};
struct NodeChar{
char character;
struct NodeChar * next;
};
struct NodeDouble{
double dou;
struct NodeDouble * next;
};
template <class T,class N>
N * create(T * array,int n)
{
N *p , *head , *q;
head = (N*)malloc(sizeof(N));
p = head;
int i = 1;
if( 0 != n )
{
while( i <= n )
{
q = (H*)malloc(sizeof(H));
q->a = array[i - 1];
p->next = q;
p = q;
i++;
}
q->next = head->next;
}
free(head);
return q->next;
}