im trying to create a short email based program that displays only the subject of each email and how many emails with that specific subject there are. However im having a few scoping errors i cant figure out in my SearchCommunication. Can anyone take a look at it and let me know what i need to do to fix the errors?
#include <iostream>
#include <string>
#include <cstddef>
using namespace std;
string line;
int sum = 0;
class List
{
public:
List(); //DEFAULT CONSTRUCTOR
List(const List& aList); //COPY CONSTRUCTOR
~List(); //DESTRUCTOR
//LIST OPERATIONS
void InsertBeg(string, int);
void Display();
private:
struct ListNode
{
string name;
int item;
ListNode* next;
ListNode* prev;
}; //END ListNode
int size;
ListNode* head;
void CopyList(ListNode* ListPtr, ListNode* &NewListPrt);
void DeleteList(ListNode* BeginPtr); //DESTRUCTOR
void SearchCommunication(string);
void DeleteCommunication(string);
};//List
List inbox;
List::List() //DEFAULT CONSTRUCTOR
{
head = NULL;
size = 0;
}
List::List(const List& aList) //COPY CONSTRUCTOR
{
CopyList(aList.head,head);
size = aList.size;
}
List::~List() //DESTRUCTOR
{
DeleteList(head);
}
//LIST OPERATIONS
void List::InsertBeg(string inputN, int Value)
{
ListNode* Temp = head;
head = new ListNode;
head -> prev = NULL;
head -> next = Temp;
head -> name = inputN;
head -> item = Value;
Temp -> prev = head;
++size;
} //END InsertBeg()
void List::Display()
{
ListNode* current = head;
while (current != NULL)
{
cout << current -> name << " - " << current -> item;
current = current -> next;
}
} //END Display()
void List::CopyList(ListNode* ListPtr, ListNode *& NewListPtr) //COPY CONSTRUCTOR
{
if (ListPtr != NULL)
{//COPY FIRST NODE}
NewListPtr = new ListNode;
NewListPtr -> item = ListPtr -> item;
NewListPtr -> name = ListPtr -> name;
NewListPtr -> next = ListPtr -> next;
NewListPtr -> prev = ListPtr -> prev;
//COPY REST (TAIL) OF LIST
CopyList(ListPtr -> next, NewListPtr -> next);
}
} //END
void List::DeleteList(ListNode* BeginPtr) //DESTRUCTOR
{
if (BeginPtr != NULL)
{
//DELETE TAIL OF LIST (ALL BUT FIRST NODE)
DeleteList(BeginPtr -> next);
delete BeginPtr;
}
} //END
//Searches the Inbox for a communication using subject as the key for the search, and
//returns a pointer to the communication node that matches the subject, or the null
//pointer if no such node is found.
void List::SearchCommunication(string word)
{
ListNode *temp = inbox.head;
while((temp->name != word) && (temp != NULL))
{
temp = temp -> next;
}
return temp;
}
//Moves an e-mail to be displayed first.
void MoveEmail()
{
}
//Deletes a communication having a given subject.
void List::DeleteCommunication(string sub)
{
MoveEmail(SearchCommunication(sub));
inbox.~List();
sum-=inbox.head.value;
}
//Inserts a new e-mail.
void InsertEmail()
{
pos = SearchCom(line);
if(pos==NULL){
inbox.InsertBeg(line, 1);
position -> innum.head;
}else
{
pos
MoveEmail(pos);
}
sum++;
}
//Displays Inbox by listing the communication in the order they appear in the
//Inbox from the most recent to the oldest, i.e., from beginning of doubly-linked list
//of communications, displaying the subject and the number of e-mails in the communication.
void DisplayInbox()
{
cout << "Inbox: total number of emails is " << sum << "." << endl << endl;
inbox.Display();
}
int main()
{
/*while(getline(cin,line) && line!="")
{
InsertEmail();
}
DisplayInbox();*/
// cin >> line;
}