Write in C++ code, compile make sure it has no warnings. I\'d really appreciate
ID: 3627468 • Letter: W
Question
Write in C++ code, compile make sure it has no warnings. I'd really appreciate it!
Using the PersonType class, extend it to keep track of when the person is created in the constructor.
Add a constructor allowing specification of the time (year, month, day, hour, minute)
Use the time.cpp for code which gets the current time to allow the current constructor to default to the present time.
Person type class files
//personType.h
#include
using namespace std;
class personType
{
public:
void print() const;
//Function to output the first name and last name
//in the form firstName lastName.
void setName(string first, string last);
//Function to set firstName and lastName according
//to the parameters.
//Postcondition: firstName = first; lastName = last
string getFirstName() const;
//Function to return the first name.
//Postcondition: The value of firstName is returned.
string getLastName() const;
//Function to return the last name.
//Postcondition: The value of lastName is returned.
personType(string first = "", string last = "");
//Constructor
//Sets firstName and lastName according to the parameters.
//The default values of the parameters are null strings.
//Postcondition: firstName = first; lastName = last
private:
string firstName; //variable to store the first name
string lastName; //variable to store the last name
};
//personTypeImp.cpp
#include
#include
#include "personType.h"
using namespace std;
void personType::print() const
{
cout << firstName << " " << lastName;
}
void personType::setName(string first, string last)
{
firstName = first;
lastName = last;
}
string personType::getFirstName() const
{
return firstName;
}
string personType::getLastName() const
{
return lastName;
}
//constructor
personType::personType(string first, string last)
{
firstName = first;
lastName = last;
}
#include
#include
using namespace std;
time.cpp files
int main()
{
time_t rawtime;
time ( &rawtime );
struct tm * timeinfo = localtime ( &rawtime );
cout << " Hour: " << timeinfo->tm_hour << endl
<< " Minute: " << timeinfo->tm_min << endl
<< " Second: " << timeinfo->tm_sec << endl
<< " Day of the month: " << timeinfo->tm_mday << endl
<< " Month: " << timeinfo->tm_mon << endl
<< " Year: " << timeinfo->tm_year << endl
<< " Day of the week: " << timeinfo->tm_wday << endl
<< " Day of the year: " << timeinfo->tm_yday << endl
<< " Is daylight saving time: " << timeinfo->tm_isdst << endl;
system("pause");
return 0;
}
//Test Program personType
#include
#include
#include "personType.h"
using namespace std;
int main()
{
personType student("Lisa", "Regan");
student.print();
cout<
return 0;
}
Explanation / Answer
DEAR FRIEND u have tow main in one program which can not be done the warning u r getting can be removed and i did it u will not have any errors in this code or warning unless for the tow main problem //personType.h #include using namespace std; class personType { public: void print() const; //Function to output the first name and last name //in the form firstName lastName. void setName(string first, string last); //Function to set firstName and lastName according //to the parameters. //Postcondition: firstName = first; lastName = last string getFirstName() const; //Function to return the first name. //Postcondition: The value of firstName is returned. string getLastName() const; //Function to return the last name. //Postcondition: The value of lastName is returned. personType(string first = "", string last = ""); //Constructor //Sets firstName and lastName according to the parameters. //The default values of the parameters are null strings. //Postcondition: firstName = first; lastName = last private: string firstName; //variable to store the first name string lastName; //variable to store the last name }; //person.cpp #include #include #include "personType.h" using namespace std; void personType::print() const { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.