我不是很擅长这个,我有点坚持为单个链表和与之配套的节点制作复制构造函数。
这是我的头文件:
#pragma once
#include <iostream>
using namespace std;
class Node
{
public:
int data;
Node* next;
Node()
{
next = NULL;
data = 0;
}
Node(const Node& copyNode); /*: data(copyNode.data), next(copyNode.next ? new Node(*copyNode.next) : NULL)*/
};
class SLLIntStorage
{
public:
Node* head;
Node* current;
Node* tail;
void Read(istream&);
void Write(ostream&);
void setReadSort(bool);
void sortOwn();
void print();
void mergeSort(Node**);
Node *merge(Node*, Node*);
void split(Node*, Node**, Node**);
bool _sortRead;
int numberOfInts;
SLLIntStorage(const SLLIntStorage& copying) //: head(copying.head ? new Node(*copying.head) : NULL)
{
}
SLLIntStorage(void);
~SLLIntStorage(void);
};
inline ostream& operator<< (ostream& out, SLLIntStorage& n)
{
n.Write(out);
return out;
}
inline istream& operator>> (istream& in, SLLIntStorage& s)
{
s.Read(in);
return in;
}
谁能帮我理解它是如何工作的以及我可以做些什么来创建它?谢谢你。