Please implement the following problem in basic C++ code and include detailed co
ID: 3604761 • Letter: P
Question
Please implement the following problem in basic C++ code and include detailed comments so that I am able to understand the processes for the solution. Thanks in advance.
// personType.h
#include <string>
// personTypeImp.cpp
// main.cpp
Please be sure that the answer matches the shown sample output!
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 Derive a class extPersonType from the class personType. Add a member variable to this class to classify the person as a family member, friend, or business associate. (Hint: you can use an Integer data type to save this information. For example, 1 for family member, 2 for friend and 3 for business associate) In addition, add a member variable to store the address (using address Type object). Add proper statements on in the main function to test you code. Use constructors to automatically initialize the member variables. Sample Output: CAWINDOWSlsystem321cmd.exe John Denver is a business associate who 1ives at 42 W Warren Ave, Wayne, MI 48202 Press any key to continue .Explanation / Answer
// only sending files which I have written, u need to use the personType.h , personType.cpp and main file together //with these given files and execute.
//extPersonType.h
#include<iostream>
using namespace std;
class extPersonType : public personType
{
int type;
addressType *addr;
public:
extPersonType(string fname, string lname, int type, addressType &addr);
virtual void print();
};
-----------------------------------------------------------------------------------------------------------------------------------
//extPersonType.cpp
#include"extPersonType.h"
extPersonType::extPersonType(string fname, string lname, int typ, addressType &add) : personType(fname,lname)
{
type = typ;
addr = new addressType(add);
}
void extPersonType::print()
{
string typeStr;
if (type == 1)
{
typeStr = "family membr";
}
if (type == 2)
typeStr = "friend";
if (type == 3)
typeStr = "business associate";
else
typeStr = "unknown";
cout << firstName << " " << lastName << " is a " << typeStr << " who lives at ";
addr->print() ;
}
---------------------------------------------------------------------------------------
//AddressType.h
#include<string>
using namespace std;
class addressType
{
string streetAddress, city, state, zip;
public:
addressType(string add, string cty, string st, string zp);
void print();
};
-------------------------------------------
//AddressType.cpp
#include "AddressType.h"
#include<iostream>
using namespace std;
addressType::addressType(string add, string cty, string st, string zp)
{
streetAddress = add;
city = cty;
state = st;
zip = zp;
}
void addressType::print()
{
cout << streetAddress << ", " << city << ", " << state << " " << zip << endl;
}
------------------------------------------------------------------------------------------------
//output
John Denver is a business associate who lives at 42 W Warren Ave, Wayne, MI 48202