Instructions: I cant get my .cpp code to work with my header code i dont underst
ID: 3709575 • Letter: I
Question
Instructions: I cant get my .cpp code to work with my header code i dont understand and need help. if needed we can do a completely new Person.cpp code
//Person.cpp
#include<iostream>
#include "Person.h"
using namespace std;
namespace college
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;
}
//Person.h
#pragma once
#ifndef Person_H
#define Person_H
#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
#endif // !Person_H
Explanation / Answer
The code is modified and the errors are solved
Person.h
#pragma once
#ifndef Person_H
#define Person_H
#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);
Person(string,string,string,string,string,string,string,string);
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
//Person.cpp
#include<iostream>
#include "Person.h"
using namespace std;
college::Person::Person()
{
}
college::Person::Person(string name, Date dob)
{
firstname = name;
DOB = dob;
}
college::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 college::Person::get_fistname()
{
return firstname;
}
string college::Person::get_lastname()
{
return lastname;
}
college::Date college::Person::get_DOB()
{
return DOB;
}
string college::Person::getaddress()
{
return address;
}
string college::Person::getcity()
{
return city;
}
string college::Person::getstate()
{
return state;
}
string college::Person::getphonenumber()
{
return phonenumber;
}
string college::Person::getethnicity()
{
return ethnicity;
}
string college::Person::getgender()
{
return Gender;
}
string college::Person::getmaritalstatus()
{
return maritalstatus;
}
string college::Person::getpersonnelemail()
{
return personnelemail;
}
void college::Person::set_dob(Date date)
{
DOB = date;
}
void college::Person::set_name(string name)
{
firstname = name;
}
void college::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;
}