Instrcution: Create a .cpp for the header file header Code: #include <string>; #
ID: 3703930 • Letter: I
Question
Instrcution: Create a .cpp for the header file
header Code:
#include <string>;
#include <iostream>;
#include <vector>;
using namespace std;
namespace college
{
struct Date
{
int month, day, year;
};//Date
class Person
{
private:
string firstname,lastname, address, city, state, zip, phonenumber, ethnicity, Gender, maritalstatus, personnelemail;
Date DOB;
int age, ssnumber;
public:
Person();
Person (string, Date);
string get_fistname();
string get_lastname(),
Person(string address, string city, string state, string phonenumber, string ethnicity, string Gender, string maritalstatus, string personnelemail);
Date get_DOB();
void getaddress(string);
void getcity(string);
void getstate(string);
void getphonenumber(string);
void getethnicity(string);
void getgender(string);
void getmaritalstatus(string);
void getpersonnelemail(string);
void set_dob(Date);
void set_name(string);
void print();
};//Person
Explanation / Answer
//Person.h
#ifndef PERSON_H
#define PERSON_H
#include<iostream>
#include<string>
using namespace std;
struct Date
{
int month, day, year;
};//Date
class Person
{
private:
string firstname,lastname, address, city, state, zip,
phonenumber, ethnicity, Gender, maritalstatus, personnelemail;
Date DOB;
int age, ssnumber;
public:
Person();
Person (string, Date);
Person(string address, string city, string state,
string phonenumber, string ethnicity,
string Gender, string maritalstatus,
string personnelemail);
string get_fistname();
string get_lastname();
Date get_DOB();
string getaddress();
string getcity();
string getstate();
string getphonenumber();
string getethnicity();
string getgender();
string getmaritalstatus();
string getpersonnelemail();
void set_dob(Date);
void set_name(string);
void print();
};//Person
#endif PERSON_H
----------------------------------------------------------------------------
//Person.cpp
//include header files
#include<iostream>
//include Person.h
#include "Person.h"
using namespace std;
Person::Person()
{
}
Person::Person (string name, Date dob)
{
firstname=name;
DOB=dob;
}
Person::Person(string address, string city, string state,
string phonenumber, string ethnicity,
string Gender, string maritalstatus,
string personnelemail)
{
this->address=address;
this->city=city;
this->state=state;
this->phonenumber=phonenumber;
this->ethnicity=ethnicity;
this->Gender=Gender;
this->maritalstatus=maritalstatus;
this->personnelemail=personnelemail;
}
string Person::get_fistname()
{
return firstname;
}
string Person::get_lastname()
{
return lastname;
}
Date Person::get_DOB()
{
return DOB;
}
string Person::getaddress()
{
return address;
}
string Person::getcity()
{
return city;
}
string Person::getstate()
{
return state;
}
string Person::getphonenumber()
{
return phonenumber;
}
string Person::getethnicity()
{
return ethnicity;
}
string Person::getgender()
{
return Gender;
}
string Person::getmaritalstatus()
{
return maritalstatus;
}
string Person::getpersonnelemail()
{
return personnelemail;
}
void Person::set_dob(Date date)
{
DOB= date;
}
void Person::set_name(string name)
{
firstname=name;
}
void Person::print()
{
cout<<"Name :"<<firstname<<" "<<lastname<<endl;
cout<<"Address : "<<address<<endl;
cout<<"City: "<<city<<endl;
cout<<"State: "<<state<<endl;
cout<<"Zip: "<<zip<<endl;
cout<<"Phone Number : "<<phonenumber<<endl;
cout<<"Ethnicity: "<<ethnicity<<endl;
cout<<"Gender : "<<Gender<<endl;
cout<<"Marital Status: "<<maritalstatus<<endl;
cout<<"Email : "<<personnelemail<<endl;
cout<<"DOB : "<<DOB.day<<"/"<<DOB.month<<"/"<<DOB.year<<endl;
}