Курсовая работа: Односвязный список на основе указателей
Node *pTail;
};
int menu();
int Correct();
4.3 Реализацияметодов
#include <iostream>
#include <cassert>
#include <cstdlib>
using namespace std;
Node::Node() {
cout<<"Enter name: ";cin>>Name;
cout<<"Enter price (use only digits): ";Price = Correct();
cout<<"Enter number (use only digits): ";Number = Correct();
cout<<"Node constructor called; new entry created\n";
}
List::List() {
pHead = NULL;
pTail = NULL;
cout<<"List constructor called; new list created\n";
}
List::~List() {
Node* pTemp;
while (pHead) {
pTemp = pHead;
pHead = pHead->pNext;
delete pTemp;
cout<<"Destroying the list...\n";
}
}