Question: C++ * Please be sure that your code is structured into the following files: - PersonType.h - PersonType.cpp - PersonTypeMain.cpp - makefile _________________________________________________________________ * Please
C++
* Please be sure that your code is structured into the following files:
- PersonType.h
- PersonType.cpp
- PersonTypeMain.cpp
- makefile
_________________________________________________________________
*Please include user input
- Add more member functions on the class extPersonType.
The following functions are needed to be added:
= assign one object to the other
== check if two objects are equal
A copy constructor
Write a C++ program to test your design. Moreover, test your design by creating pointers.
CODE:
#include
using namespace std;
class addressType
{
protected:
string street, city, state, zip;
public:
addressType(string s, string c, string st, string z)
{
street = s;
city = c;
state = st;
zip = z;
}
void setStreet(string s)
{
street = s;
}
void setCity(string c)
{
city = c;
}
void setState(string s)
{
state = s;
}
void setZip(string z)
{
zip = z;
}
void print()
{
cout << "Street: " << street << endl;
cout << "City: " << city << endl;
cout << "State: " << state << endl;
cout << "ZIP: " << zip << endl;
}
};
class personType
{
protected:
string fname, lname;
public:
personType(string fn, string ln)
{
fname = fn;
lname = ln;
}
void setFirstName(string fn)
{
fname = fn;
}
void setLastName(string ln)
{
lname = ln;
}
void print()
{
cout << "First Name: " << fname << endl;
cout << "Last Name: " << lname << endl;
}
};
class dataType
{
protected:
int day, month, year;
public:
dataType(int d, int m, int y)
{
day = d;
month = m;
year = y;
}
void setDay(int d)
{
day = d;
}
void setMonth(int m)
{
month = m;
}
void setYear(int y)
{
year = y;
}
void print()
{
cout << "Day: " << day << endl;
cout << "Month: " << month << endl;
cout << "Year: " << year << endl;
}
};
class extPersonType : public addressType, public personType, public dataType
{
private:
string person, phoneNumber;
public:
extPersonType(string p, string pn, string s, string c, string st, string z, string fn, string ln, int d, int m, int y) : addressType(s, c, st, z), personType(fn, ln), dataType(d, m, y)
{
person = p;
phoneNumber = pn;
}
void setPerson(string p)
{
person = p;
}
void setPhoneNumber(string pn)
{
phoneNumber = pn;
}
void print()
{
cout << " ";
cout << "The person details are: " << endl << endl;
cout << "First Name: " << fname << endl;
cout << "Last Name: " << lname << endl;
cout << "Street: " << street << endl;
cout << "City: " << city << endl;
cout << "State: " << state << endl;
cout << "ZIP: " << zip << endl;
cout << "Day: " << day << endl;
cout << "Month: " << month << endl;
cout << "Year: " << year << endl;
cout << "Person Type: " << person << endl;
cout << "Phone Number: " << phoneNumber << endl << endl;
}
};
int main()
{
extPersonType person("Friend", "361-825-5700", "6300 Ocean Dr.", "Corpus Christi", "Texas", "78412", "Justin", "Saenz", 4, 9, 2018);
person.print();
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
