C++教程:C++友元类讲解

2020-01-06 12:20:36王旭

   Node head;
   Node * pcurrent;
};
Linklist::Linklist(int i,char c):head(i,c)//链表的构造函数
{
   cout<<"Linklist constructor is running..."<<endl;
   pcurrent=&head;
}
Linklist::Linklist(Linklist &l):head(l.head)
{
   cout<<"Linklist Deep cloner running..." <<endl;
   pcurrent=&head;
   Node * ptemp1=l.head.next;//直接访问私有成员数据
   while(ptemp1!=NULL)
   {
      Node * ptemp2=new Node(ptemp1->idata,ptemp1->cdata,pcurrent,NULL);
      pcurrent->next=ptemp2;
      pcurrent=pcurrent->next;