怎么编主函数啊
#include<iostream.h>struct node
{
int data;
node*next;
};
class list
{
node*head;
public:
list(){head=NULL;}
void inserlist(int adata,int bdata);
void deletelist(int adata);
void outputlist();
node*gethead(){return head;}
};
void list::inserlist(int adata,int bdata)
{
node *p,*q,*s;
s=(node*)new(node);
s->data=bdata;
p=head;
if(head==NULL)
{
head=s;
s->next=NULL;
}
else
if(p->data==adata)
{
s->next=p;
head=s;
}
else
{
while(p->data!=adata&&p->next!=NULL)
{
q=p;
p=p->next;
}
if(p->data==adata)
{
q->next=s;
s->next=p;
}
else
{
p->next=s;
s->next=NULL;
}
}
}
void list::outputlist()
{
node *current=head;
while(current!=NULL)
{
cout<<current->data<<" ";
current=current->next;
}
cout<<endl;
}
void main()
{
list A,B;
int data[12]={21,22,23,24,25,26,27,28,1,2};
int a=2;
A.inserlist(21,data[3]);
for
A.outputlist();
}
怎么编主函数,才能调用void list::inserlist(int adata,int bdata),在ADATA后面加上所需要的数字