Another problem but it's in the Print function of the Hybrid class. I don't get any errors but the output is not what I expected. I need all of the elements of the struct to display as output but the program only display the first element of the struct and the other elements are blank lines. So the program knows that the elements are there but instead of text it's several blank lines.
My code is below. Thanks.
Code:
#include <iostream>
#include <string>
#include <fstream>
#include "HybridList.h"
using namespace std;
struct me
{
ComponentType lName;
ComponentType fName;
ComponentType mName;
ComponentType title;
ComponentType companyName;
ComponentType streetAddress;
ComponentType city;
ComponentType state;
ComponentType zipCode;
ComponentType phoneNumber;
ComponentType faxNumber;
ComponentType emailAddress;
};
int main()
{
HybridList list1;
me contact;
char another;
cout << "Enter last name: ";
getline(cin, contact.lName);
cout << "Enter first name: ";
getline(cin, contact.fName);
cout << "Enter middle name: ";
getline(cin, contact.mName);
cout << "Enter title: ";
getline(cin, contact.title);
cout << "Enter company name: ";
getline(cin, contact.companyName);
cout << "Enter street address: ";
getline(cin, contact.streetAddress);
cout << "Enter city: ";
getline(cin, contact.city);
cout << "Enter state: ";
getline(cin, contact.state);
cout << "Enter zip code: ";
getline(cin, contact.zipCode);
cout << "Enter phone number: ";
getline(cin, contact.phoneNumber);
cout << "Enter fax number: ";
getline(cin, contact.faxNumber);
cout << "Enter e-mail address: ";
getline(cin, contact.emailAddress);
list1.Insert(contact.lName);
list1.Print();
cout << "Would you like to enter another contact(Y/N): ";
cin >> another;
..... program continues .....
}
//*************************************************************
void HybridList::Print() const
// Postcondition:
// component members of all nodes (if any) in linked list
// have been output
{
mePtr currPtr = head; // Loop control pointer
while (currPtr != NULL)
{
cout << currPtr->lName << endl;
cout << currPtr->fName << endl;
cout << currPtr->mName << endl;
cout << currPtr->title << endl;
cout << currPtr->companyName << endl;
cout << currPtr->streetAddress << endl;
cout << currPtr->city << endl;
cout << currPtr->state << endl;
cout << currPtr->zipCode << endl;
cout << currPtr->phoneNumber << endl;
cout << currPtr->faxNumber << endl;
cout << currPtr->emailAddress << endl;
currPtr = currPtr->link;
}
}
I think it have something to do with passing the struct to the class.