IN C++ I understand how to make the classes, having trouble implementing use, Th
ID: 3904489 • Letter: I
Question
IN C++
I understand how to make the classes, having trouble implementing use, Thanks!
Using classes and arrays, design an Online Address Book to keep track of the names, addresses, phone numbers, and dates of birth of family members, close friends, and certain business associates.
Your program should be able to handle as many entries as required.
1. Define a class, addressType, that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables.
2. Define a class, personType , that can store the first name and the last name of a person. Use the appropriate functions to print and store the first and the last name. Also, use constructors toautomatically initialize the member variables.
3. Define a class,dataType, that can store the day, the month, and the year of a date. Use the appropriate functions to print and store the day, the month, and the year. Also, use constructors to automatically initialize the member variables.
4. Define a class extPersonType. The class is a derived class from the above classes. The class adds a member variable to classify the person as a family member, friend, or business associate. Also, the class adds a member variable to store the phone number. Moreover, the class adds (or override) functions to print and store the appropriate information. Use constructors to automatically initialize the member variables.
5. Define the class addressBookType using the previously defined classes. An object of the type addressBookType should be able to process as many entries as required.
6. Write a C++ program to test your design. The program should perform the following operations:
–
Add a new entry to the address book.
–
Delete an entry from the address book.
–
Print all the information of the addres
Explanation / Answer
main.cpp
#include <iostream>
#include <fstream> // for files
#include <string>
#include "addressBookType.h"
using namespace std;
void menu();
int main() {
addressBookType addressBook;
//load address book
addressBook.load(addressBook);
string choice = " ";
while (choice != "1" && choice != "2" && choice != "3" && choice != "4" && choice != "5" &&
choice != "6" && choice != "7" && choice != "8") {
menu();
cout << endl;
getline(cin, choice);
if (choice == "1") {
system("cls");
string lastNameToFind;
extPersonType personToFind;
cout << "Find a person by last name (cAsE sEnSiTiVe!): " << endl;
getline(cin, lastNameToFind);
personToFind.setLastName(lastNameToFind);
addressBook.print(personToFind);
system("pause");
choice = " ";
} else if(choice == "2") {
int birthdayMonth = 100;
while (birthdayMonth > 12 || birthdayMonth < 0) {
system("cls");
cout << "Print all birthdays within a given month: " << endl;
cout << "Use numbers (ex. Jan = 1, Feb = 2... Dec = 12) ONLY" << endl;
cin >> birthdayMonth;
cin.ignore();
cin.clear();
dateType date;
date.setMonth(birthdayMonth);
addressBook.print(date, date);
}
system("pause");
choice = " ";
} else if (choice == "3") {
char choix = ' ';
while (choix != '1' && choix != '2' && choix != '3' && choix != '4' && choix != '5') {
system("cls");
cout << "Print entries with a relationship of:" << endl
<< "1. Family" << endl << "2. Friend" << endl << "3. Business"
<< endl << "4. Other" << endl << "5. Exit" << endl << endl;
cin.get(choix);
if (choix == '1') {
addressBook.print(FAMILY);
}else if (choix == '2') {
addressBook.print(FRIEND);
}else if (choix == '3') {
addressBook.print(BUSINESS);
}else if (choix == '4') {
addressBook.print(OTHER);
}
}
system("pause");
choice = " ";
} else if (choice == "4") {
string name1;
string name2;
system("cls");
cout << "Print all entries with last names alphabetically between two names" << endl;
cout << "Name 1: " << endl;
getline(cin, name1);
cout << "Name 2: " << endl;
getline(cin, name2);
addressBook.print(name1, name2);
system("pause");
choice = " ";
} else if (choice == "5") {
addressBook.insertEnd(addressBook.addEntry());
system("pause");
choice = " ";
} else if (choice == "6") {
addressBook.deleteEntry(addressBook);
system("pause");
choice = " ";
} else if (choice == "7") {
addressBook.print();
system("pause");
choice = " ";
}
}
string save;
cout << "Save Address Book? y/Y" << endl;
getline(cin, save);
if (save == "y" || save == "Y")
addressBook.save(addressBook);
system("pause");
return 0;
}
void menu() {
system("cls");
cout << "Address Book" << endl << endl;
cout << "Menu: " << endl << "1. Search By Last Name" << endl
<< "2. Print Those with a birthday in given month" << endl
<< "3. Print friends, family, business or other" << endl
<< "4. Print between two last names" << endl
<< "5. Add a new entry" << endl
<< "6. Delete an entry" << endl
<< "7. Print entire address book" << endl
<< "8. Exit" << endl;
}
addressBookType.cpp
#include "addressBookType.h"
#include <fstream>
addressBookType::addressBookType()
:arrayListType<extPersonType>(500) {
}
addressBookType::addressBookType(const string& new_fileName) {
}
int addressBookType::find(const string& lastName) const {
bool isInAddressBook = false;
int p = 0;
for (p = 0; p < length; p++)
if (list[p].getLastName() == lastName) {
isInAddressBook = true;
}
return isInAddressBook == true ? p : -1;
}
void addressBookType::print(const extPersonType& person) const {
system("cls");
bool isFound = false;
for (int i = 0; i < length; i++) {
if (person.getLastName() == list[i].getLastName()) {
list[i].print();
isFound = true;
}
}
if (!isFound) {
cout << endl << "Last Name " << person.getLastName() << " not in address book" << endl;
}
}
void addressBookType::print(relationShipType relationship) const {
system("cls");
for (int r = 0; r < length; r++)
if (list[r].getRelationShip() == int(relationship)) {
list[r].print();
}
}
void addressBookType::print(const dateType& oldDate, const dateType& newDate) const {
system("cls");
dateType tempDate;
int tempMonth;
for (int d = 0; d < length; d++) {
tempDate = list[d].getDOB();
tempMonth = tempDate.getMonth();
if (oldDate.getMonth() == tempMonth) {
list[d].print();
}
}
}
void addressBookType::print(const string& highLastName, const string& lowLastName) const {
string high, low;
if (highLastName > lowLastName) { //if the user enters them backwards.
high = highLastName;
low = lowLastName;
} else {
high = lowLastName;
low = highLastName;
}
system("cls");
for (int i = 0; i < length; i++) {
if (list[i].getLastName() >= low && list[i].getLastName() <= high) {
list[i].print();
}
}
}
void addressBookType::print() const {
system("cls");
if (length < 1) {
cout << "address book empty!" << endl;
} else {
for (int n = 0; n < length; n++) {
list[n].print();
}
cout << length << " Total Entries!" << endl;
}
}
void addressBookType::deleteEntry(addressBookType &addressBook) {
system("cls");
string toDelete;
bool isFound = false;
cout << "Delete an entry" << endl;
cout << "Enter a last name to delete from the address book: " << endl;
getline(cin, toDelete);
for (int d = 0; d < length; d++) {
if (!isFound){
if (list[d].getLastName() == toDelete) {
addressBook.removeAt(d);
cout << toDelete << " removed!" << endl;
isFound = true;
}
}
}
if (!isFound) {
cout << "Name not found" << endl;
}
}
extPersonType addressBookType::addEntry() {
system("cls");
cout << "New Entry: " << endl;
string fname, lname, street, city, state, zip, phone;
int month, day, year;
relationShipType r;
dateType dob;
cout << "First Name: " << endl;
getline(cin, fname);
cout << "Last Name: " << endl;
getline(cin, lname);
cout << "Street Address: " << endl;
getline(cin, street);
cout << "City: " << endl;
getline(cin, city);
cout << "State (2 digit abbreviation): " << endl;
getline(cin, state);
cout << "Zip Code: " << endl;
getline(cin, zip);
cout << "Phone Number: " << endl;
getline(cin, phone);
cout << "Day of Birth: " << endl;
cin >> day;
cin.ignore();
cin.clear();
cout << "Month Of Birth: " << endl;
cin >> month;
cin.ignore();
cin.clear();
cout << "Year Of Birth: " << endl;
cin >> year;
cin.ignore();
cin.clear();
dob.setDate(month, day, year);
int rtype = 0;
while (rtype != 1 && rtype != 2 && rtype != 3 && rtype != 4) {
cout << "Relationship Type: " << endl;
cout << "1. Friend" << endl << "2. Family" << endl << "3. Business" << endl << "4. Other" << endl;
cin >> rtype;
cin.ignore();
cin.clear();
if (rtype == 1) {
r = FRIEND;
} else if (rtype == 2) {
r = FAMILY;
} else if (rtype == 3) {
r = BUSINESS;
} else if (rtype == 4) {
r = OTHER;
}
}
extPersonType newPerson(fname, lname, phone, dob, r);
newPerson.setAddress(street, city, state, zip);
return newPerson;
}
void addressBookType::load(addressBookType &addressBook) {
ifstream infile;
string fname, lname;
string street, city, state, zip, phone;
int relationship;
relationShipType r;
int month, day, year;
dateType dob;
extPersonType temp; //to hold all temp data for each entry
infile.open("addressBook.txt");
if (!infile) {
cout << "Cannot locate file. " << endl;
return;
}
int i = 0;
while (infile >> fname) {
//infile >> fname;
infile >> lname;
infile >> month >> day >> year;
infile.ignore(1000, ' ');
getline(infile, street);
getline(infile, city);
getline(infile, state);
getline(infile, zip);
getline(infile, phone);
infile >> relationship;
dob.setDate(month, day, year);
r = static_cast<relationShipType>(relationship);
temp.setExtPerson(fname, lname, phone, dob, r);
temp.setAddress(street, city, state, zip);
addressBook.insertAt(i, temp);
i++;
}
}
void addressBookType::save(addressBookType addressBook) {
ofstream outfile;
outfile.open("addressBook.txt");
if (!outfile) {
cout << "Input file does not exists. "
<< "Program terminates!!!" << endl;
return;
}
string fname, lname;
string street, city, state, zip, phone;
relationShipType r;
dateType dob;
for (int i = 0; i < addressBook.length; i++) {
fname = addressBook.list[i].getFirstName();
lname = addressBook.list[i].getLastName();
dob = addressBook.list[i].getDOB();
phone = addressBook.list[i].getTelephoneNumber();
street = addressBook.list[i].getStreetAddress();
city = addressBook.list[i].getCity();
state = addressBook.list[i].getState();
zip = addressBook.list[i].getZipCode();
r = addressBook.list[i].getRelationShip();
outfile << fname << endl;
outfile << lname << endl;
outfile << dob.getMonth() << " " << dob.getDay() << " " << dob.getYear() << endl;
outfile << street << endl;
outfile << city << endl;
outfile << state << endl;
outfile << zip << endl;
outfile << phone << endl;
outfile << r << endl << endl;
}
}
addressBookType.h
#pragma once
#include "arrayListType.h"
#include "addressType.h"
#include "extPersonType.h"
class addressBookType :
public arrayListType<extPersonType>
{
public:
//constructors
addressBookType();
addressBookType(const string& new_fileName);
void addressBookType::load(addressBookType &addressBook);
void addressBookType::save(addressBookType addressBook);
void addressBookType::deleteEntry(addressBookType &addressBook);
extPersonType addressBookType::addEntry();
int find(const string& lastName) const;
void print(const extPersonType& person) const;
void print(relationShipType relationship) const;
void print(const dateType& oldDate, const dateType& newDate) const;
void print(const string& highLastName, const string& lowLastName) const;
void print() const;
};
addressType.cpp
#include "addressType.h"
#include <iostream>
using namespace std;
addressType::addressType() {
setAddress("855 North Vermont Avenue", "Los Angeles", "California", "90029");
}
addressType::addressType(const string& new_streetAddress, const string& new_city,
const string& new_state, const string& new_zipCode) {
setAddress(new_streetAddress, new_city, new_state, new_zipCode);
}
//accessors
void addressType::getAddress() const {
cout << getStreetAddress() << endl;
cout << getCity() << endl;
cout << getState() << endl;
cout << getZipCode() << endl;
}
string addressType::getStreetAddress() const {
return _streetAddress;
}
string addressType::getCity() const {
return _city;
}
string addressType::getState() const {
return _state;
}
string addressType::getZipCode() const {
return _zipCode;
}
//mutators
void addressType::setAddress(const string& new_streetAddress, const string& new_city,
const string& new_state, const string& new_zipCode) {
_streetAddress = new_streetAddress;
_city = new_city;
_state = new_state;
_zipCode = new_zipCode;
}
void addressType::setStreetAddress(const string& new_streetAddress) {
_streetAddress = new_streetAddress;
}
void addressType::setCity(const string& new_city) {
_city = new_city;
}
void addressType::setState(const string& new_state) {
_state = new_state;
}
void addressType::setZipCode(const string& new_zipCode) {
_zipCode = new_zipCode;
}
addressType.h
#pragma once
#include <string>
using namespace std;
class addressType
{
public:
//constructors
addressType();
addressType(const string& new_streetAddress, const string& new_city, const string& new_state, const string& new_zipCode);
//accessors
void getAddress() const;
string getStreetAddress() const;
string getCity() const;
string getState() const;
string getZipCode() const;
//mutators
void setAddress(const string& new_streetAddress, const string& new_city, const string& new_state, const string& new_zipCode);
void setStreetAddress(const string& new_streetAddress);
void setCity(const string& new_city);
void setState(const string& new_state);
void setZipCode(const string& new_zipCode);
private:
string _streetAddress;
string _city;
string _state;
string _zipCode;
};
arrayListType.h
#ifndef H_arrayListType
#define H_arrayListType
#include <iostream>
#include <cassert>
using namespace std;
template <class elemType>
class arrayListType
{
public:
const arrayListType<elemType>& operator=(const arrayListType<elemType>&);
bool isEmpty() const;
bool isFull() const;
int listSize() const;
int maxListSize() const;
void print() const;
bool isItemAtEqual(int location, const elemType& item) const;
void insertAt(int location, const elemType& insertItem);
void insertEnd(const elemType& insertItem);
void removeAt(int location);
void retrieveAt(int location, elemType& retItem) const;
void replaceAt(int location, const elemType& repItem);
void clearList();
int seqSearch(const elemType& item) const;
void insert(const elemType& insertItem);
void remove(const elemType& removeItem);
arrayListType(int size = 100);
arrayListType(const arrayListType<elemType>& otherList);
~arrayListType();
protected:
elemType *list; //array to hold the list elements
int length; //to store the length of the list
int maxSize; //to store the maximum size of the list
};
template <class elemType>
bool arrayListType<elemType>::isEmpty() const
{
return (length == 0);
}
template <class elemType>
bool arrayListType<elemType>::isFull() const
{
return (length == maxSize);
}
template <class elemType>
int arrayListType<elemType>::listSize() const
{
return length;
}
template <class elemType>
int arrayListType<elemType>::maxListSize() const
{
return maxSize;
}
template <class elemType>
void arrayListType<elemType>::print() const
{
for (int i = 0; i < length; i++)
cout << list[i] << " ";
cout << endl;
}
template <class elemType>
bool arrayListType<elemType>::isItemAtEqual(int location, const elemType& item) const
{
return (list[location] == item);
}
template <class elemType>
void arrayListType<elemType>::insertAt(int location, const elemType& insertItem)
{
if (location < 0 || location >= maxSize)
cerr << "The position of the item to be inserted is out of range" << endl;
else
if (length >= maxSize) //list is full
cerr << "Cannot insert in a full list" << endl;
else
{
for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at the
//specified position
length++; //increment the length
}
} //end insertAt
template <class elemType>
void arrayListType<elemType>::insertEnd(const elemType& insertItem)
{
if (length >= maxSize) //the list is full
cerr << "Cannot insert in a full list" << endl;
else
{
list[length] = insertItem; //insert the item at the end
length++; //increment the length
}
} //end insertEnd
template <class elemType>
void arrayListType<elemType>::removeAt(int location)
{
if (location < 0 || location >= length)
cerr << "The location of the item to be removed is out of range" << endl;
else
{
list[location] = list[length - 1];
length--;
}
} //end removeAt
template <class elemType>
void arrayListType<elemType>::retrieveAt(int location, elemType& retItem) const
{
if (location < 0 || location >= length)
cerr << "The location of the item to be retrieved is out of range." << endl;
else
retItem = list[location];
} //end retrieveAt
template <class elemType>
void arrayListType<elemType>::replaceAt(int location, const elemType& repItem)
{
if (location < 0 || location >= length)
cerr << "The location of the item to be replaced is out of range." << endl;
else
list[location] = repItem;
} //end replaceAt
template <class elemType>
void arrayListType<elemType>::clearList()
{
length = 0;
} //end clearList
template <class elemType>
int arrayListType<elemType>::seqSearch(const elemType& item) const
{
int loc;
bool found = false;
for (loc = 0; loc < length; loc++)
if (list[loc] == item)
{
found = true;
break;
}
if (found)
return loc;
else
return -1;
} //end seqSearch
template <class elemType>
void arrayListType<elemType>::insert(const elemType& insertItem)
{
int loc;
if (length == 0) //list is empty
list[length++] = insertItem; //insert the item and
//increment the length
else if (length == maxSize)
cerr << "Cannot insert in a full list." << endl;
else
{
loc = seqSearch(insertItem);
if (loc == -1) //the item to be inserted
//does not exist in the list
list[length++] = insertItem;
else
cerr << "the item to be inserted is already in the list. No duplicates are allowed." << endl;
}
} //end insert
template<class elemType>
void arrayListType<elemType>::remove(const elemType& removeItem)
{
int loc;
if (length == 0)
cerr << "Cannot delete from an empty list." << endl;
else
{
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
else
cout << "The item to be deleted is not in the list." << endl;
}
} //end remove
template <class elemType>
arrayListType<elemType>::arrayListType(int size)
{
if (size < 0)
{
cerr << "The array size must be positive. Creating an array of size 100. " << endl;
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new elemType[maxSize];
assert(list != NULL);
}
template <class elemType>
arrayListType<elemType>::~arrayListType()
{
delete [] list;
}
template <class elemType>
arrayListType<elemType>::arrayListType(const arrayListType<elemType>& otherList)
{
maxSize = otherList.maxSize;
length = otherList.length;
list = new elemType[maxSize]; //create the array
assert(list != NULL); //terminate if unable to allocate
//memory space
for (int j = 0; j < length; j++) //copy otherList
list [j] = otherList.list[j];
} //end copy constructor
template <class elemType>
const arrayListType<elemType>& arrayListType<elemType>::operator=(const arrayListType<elemType>& otherList)
{
if (this != &otherList) //avoid self-assignment
{
delete [] list;
maxSize = otherList.maxSize;
length = otherList.length;
list = new elemType[maxSize]; //create the array
assert(list != NULL); //if unable to allocate memory
//space, terminate the program
for (int i = 0; i < length; i++)
list[i] = otherList.list[i];
}
return *this;
}
#endif
dateType.cpp
#include "dateType.h"
int dateType::dom[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
dateType::dateType() {
setDate(1, 1, 1900);
}
dateType::dateType(int new_month, int new_day, int new_year) {
setDate(new_month, new_day, new_year);
}
//accessors
void dateType::getDate(int& new_month, int& new_day, int& new_year) const {
}
int dateType::getMonth() const {
return _month;
}
int dateType::getDay() const {
return _day;
}
int dateType::getYear() const {
return _year;
}
//mutators
void dateType::setDate(int new_month, int new_day, int new_year) {
setMonth(new_month);
setDay(new_day);
setYear(new_year);
}
void dateType::setMonth(int new_month) {
_month = new_month;
}
void dateType::setDay(int new_day) {
_day = new_day;
}
void dateType::setYear(int new_year) {
_year = new_year;
}
//custom methods
bool dateType::isLeapYear() const {
return (_year % 4 == 0) && (_year % 100 != 0) || (_year % 400 == 0) ? true : false;
}
dateType.h
#pragma once
class dateType {
public:
dateType();
dateType(int new_month, int new_day, int new_year);
void getDate(int& new_month, int& new_day, int& new_year) const;
int getMonth() const;
int getDay() const;
int getYear() const;
void setDate(int new_month, int new_day, int new_year);
void setMonth(int new_month);
void setDay(int new_day);
void setYear(int new_year);
bool isLeapYear() const;
private:
//data members
int _month;
int _day;
int _year;
static int dom[];
};
extPersonType.cpp
#include "extPersonType.h"
#include "addressType.h"
#include <iostream>
extPersonType::extPersonType() {
dateType defaultDOB;
setExtPerson("Matt", "Belluardo", "555-5555", defaultDOB, OTHER);
}
extPersonType::extPersonType(const string& new_firstName, const string& new_lastName,
const string& new_telephoneNumber, const dateType& new_dob, relationShipType new_relationship) {
setFirstName(new_firstName);
setLastName(new_lastName);
setTelephoneNumber(new_telephoneNumber);
setDOB(new_dob);
setRelationShip(new_relationship);
}
void extPersonType::getExtPerson(string& new_firstName, string& new_lastName,
string& new_telephoneNumber, dateType& new_dob, relationShipType& new_relationship) const {
}
string extPersonType::getFirstName() const {
return personType::getFirstName();
}
string extPersonType::getLastName() const {
return personType::getLastName();
}
string extPersonType::getTelephoneNumber() const {
return _telephoneNumber;
}
dateType extPersonType::getDOB() const{
return dob;
}
relationShipType extPersonType::getRelationShip() const {
return _relationship;
}
void extPersonType::setExtPerson(const string& new_firstName, const string& new_lastName,
const string& new_telephoneNumber, const dateType& new_dob, relationShipType new_relationship) {
personType::setName(new_firstName, new_lastName);
setTelephoneNumber(new_telephoneNumber);
setDOB(new_dob);
setRelationShip(new_relationship);
}
void extPersonType::setFirstName(const string& new_firstName) {
personType::setFirstName(new_firstName);
}
void extPersonType::setLastName(const string& new_lastName) {
personType::setLastName(new_lastName);
}
void extPersonType::setTelephoneNumber(const string& new_telephoneNumber) {
_telephoneNumber = new_telephoneNumber;
}
void extPersonType::setDOB(const dateType& new_dob) {
dob = new_dob;
}
void extPersonType::setRelationShip(relationShipType new_relationShip) {
_relationship = new_relationShip;
}
void extPersonType::print() const {
cout << getFirstName() << endl;
cout << getLastName() << endl;
cout << getTelephoneNumber() << endl;
dateType dob = getDOB();
cout << dob.getDay() << " " << dob.getMonth() << " " << dob.getYear() << endl;
relationShipType r = getRelationShip();
if (r == 0) {
cout << "FAMILY" << endl;
} else if (r == 1) {
cout << "FRIEND" << endl;
} else if (r == 2) {
cout << "BUSINESS" << endl;
} else if (r == 3) {
cout << "OTHER" << endl;
}
getAddress();
cout << endl;
}
extPersonType.h
#pragma once
#include "dateType.h"
#include "personType.h"
#include "addressType.h"
enum relationShipType {FAMILY, FRIEND, BUSINESS, OTHER};
class extPersonType : public addressType,
public personType
{
public:
//constructors
extPersonType();
extPersonType(const string& new_firstName, const string& new_lastName, const string& new_telephoneNumber, const dateType& new_dob, relationShipType new_relationship);
void getExtPerson(string& new_firstName, string& new_lastName, string& new_telephoneNumber, dateType& new_dob, relationShipType& new_relationship) const;
string getFirstName() const;
string getLastName() const;
string getTelephoneNumber() const;
dateType getDOB() const;
relationShipType getRelationShip() const;
void setExtPerson(const string& new_firstName, const string& new_lastName, const string& new_telephoneNumber, const dateType& new_dob, relationShipType new_relationship);
void setFirstName(const string& new_firstName) ;
void setLastName(const string& new_lastName) ;
void setTelephoneNumber(const string& new_telephoneNumber);
void setDOB(const dateType& new_dob);
void setRelationShip(relationShipType new_relationShip);
void print() const;
private:
string _telephoneNumber;
relationShipType _relationship;
dateType dob;
};
personType.cpp
#include <iostream>
#include <string>
#include "personType.h"
using namespace std;
void personType::print() const {
cout << firstName << " " << lastName;
}
void personType::setName(string first, string last) {
firstName = first;
lastName = last;
}
void personType::setFirstName(string first) {
firstName = first;
}
void personType::setLastName(string last) {
lastName = last;
}
string personType::getFirstName() const {
return firstName;
}
string personType::getLastName() const {
return lastName;
}
//Default constructor
personType::personType() {
firstName = "";
lastName = "";
}
//Constructor with parameters
personType::personType(string first, string last) {
firstName = first;
lastName = last;
}
personType.h
#include <string>
using namespace std;
class personType{
public:
void print() const;
void setName(string first, string last);
void personType::setFirstName(string first);
void personType::setLastName(string last);
string getFirstName() const;
string getLastName() const;
personType();
personType(string first, string last);
private:
string firstName; //variable to store the first name
string lastName; //variable to store the last name
};