単独でリンクされたリストが空かどうかを判断するための最良かつ最も簡単な方法を見つけようとしています。
ブールメソッドを作成する必要がありますか?
ありがとう
読み取り方法
void List::Read(istream& r) {
char c[13];
r >> c;
r >> numberOfInts;
Node *node = new Node();
for(int i = 0; i < numberOfInts; i++)
{
r >> node->data;
cout << node->data << endl;
node->next = new Node;
//node = node->next;
head = node;
}
}
else
{
if(node->data > head->data)
{
head->next;
}
else if(node->data < head->data)
{
Node* tempNode;
tempNode = head;
head->data = node->data;
node->data = tempNode->data;
}
}
system("pause");
}
ヘッダーファイル
class Node
{
public:
Node() {}
Node(int d, Node* q = 0) : data(d), next(q) {} //constructor with parameters data and next
int data; //holds data in node
Node* next;//pointer to next node
};
class List
{
public:
void Read(istream&);
void Write(ostream&);
void setReadSort(bool);
void sortOwn();
void insertionSort(Node*);
bool isEmpty();
bool _sortRead;
int numberOfInts;
List(void);
~List(void);
protected:
Node *head;
Node current;
};