数据结构c++循环单链表问题,急!! 5C

CirSinglyList& operator+=(CirSinglyList &list) //尾插入list,集合并

c++

2个回答

 CirSinglyList& operator+=(CirSinglyList &list)
 {
     CirSinglyList *p = this;
     while(p->next != NULL)
         p = p->next;
     while(list->next != NULL)
     {
         p->next = new CirSinglyList();
         p->next = list;
         p = p->next;
     }
     p->next = NULL;
     return this;
 }
 CirSinglyList & operator=(CirSinglyList &list)
 {
 /* 自己写 */
 }

修改一下

  CirSinglyList& operator+=(CirSinglyList &list)
 {
     CirSinglyList *p = this;
     while(p->next != NULL)
         p = p->next;
     while(list->next != NULL)
     {
         p->next = new CirSinglyList();
         p->next = list;
         p = p->next;
        list = list->next;
     }
     p->next = NULL;
     return this;
 }
 CirSinglyList& operator=(CirSinglyList &list)
 {
 /* 自己写 */
 }
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐