Question

Complete the missing code for the constructors as indicated in the comments in all three header...

Complete the missing code for the constructors as indicated in the comments in all three header files. C++

mainDriver.cpp

#include <string>
#include "Address.h"
#include "Date.h"
#include "Person.h"

using namespace std;

int main() {
   Person p1;
   Person p2("Smith", "Bobby", "[email protected]", 111, "Main St", "Clemson",
           "SC", 29630, 1, 31, 1998);
   cout << endl << endl;

   p1.printInfo();
   p2.printInfo();

   return 0;
}

Person.h

#ifndef PERSON_H
#define PERSON_H

#include <iostream>
#include <string>

using namespace std;

class Person {
   private:
       string last;
       string first;
       string email;
       Address address;
       Date bday;
   public:
   // Complete both Person constructors
  
   // default constructor with an initialization list
   // initializing a Person with these values:
   // name: John Doe
   // email: jdoe@
   // address: 0 Main St Clemson SC 29630
   // birthday: 1, 1, 1
   // include print statement that says:
   // default Person constructor
       Person()
      
      
      
      
      
      
      
      
       // regular, parameterized, constructor with an initialization list
   // initializing a Person with these values:
   // name: John Doe
   // email: jdoe@
   // address: 0 Main St Clemson SC 29630
   // birthday: 1, 1, 1
   // include print statement that says:
   // regular Person constructor
       Person(string l, string f, string e,
               int house, string street, string city, string state, int zip,
               int month, int day, int year)
                 
                 
          
                 
                 
                 
                 
                 
       ~Person() {
           cout << "Person destructor " << endl;
       }
       void printInfo();
};

ostream &operator<<(ostream& out, Address a) {
   out << a.getHouse() << " " << a.getStreet() << " "
       << a.getCity() << ", " << a.getState() << " "
       << a.getZip();
   return out;
}

ostream &operator<<(ostream& out, Date d) {
   out << d.getMonth() << " " << d.getDay() << " "
       << d.getYear();
   return out;
}

void Person::printInfo() {
   cout << endl << last << ", " << first << ", " << email << endl;
   cout << address << bday << endl << endl;
}

#endif

Date.h

#ifndef DATE_H
#define DATE_H

#include <iostream>
#include <string>

using namespace std;

class Date {
   private:
       int month, day, year;
   public:
       Date();
      
       // complete the parameterized Date constructor with
       // with an initialization list
       // include print statement that says:
   // Date constructor
       Date(int m, int d, int y)
      
      
      
      
      
      
       ~Date() {
           cout << "Date destructor " << endl;
       }
       int getMonth() { return month; }
       int getDay() { return day; }
       int getYear() { return year; }
      
};

#endif

Address.h

#ifndef ADDRESS_H
#define ADDRESS_H

#include <iostream>
#include <string>

using namespace std;

class Address {
   private:
       int house;
       string street;
       string city;
       string state;
       int zip;
   public:
   // complete the parameterized Address constructor with
       // with an initialization list
       // include print statement that says:
   // Address constructor
       Address(int h, string str, string c, string st, int z)
      
      
      
      
      
      
      
       ~Address() {
           cout << "Address destructor " << endl;
       }
       int getHouse() { return house; }
       string getStreet() { return street; }
       string getCity() { return city; }
       string getState() { return state; }
       int getZip() { return zip; }

};

#endi

Homework Answers

Answer #1

Here are your constructors:

Default Constructor Person:

Person() : last("Doe"), first("John"), email("jdoe@"), address(0, "Main St", "Clemson", "SC", 29630), Date(1,1,1) {
   cout<<"default Person constructor.\n";
   }

Regular Constructor Person:

Person(string l, string f, string e, int house, string street, string city, string state, int zip, int month, int day, int year): last(l), first(f), email(e), address(house,street,city,state,zip), Date(month, day, year) {
   cout<<"regular Person constructor.\n";
   }

Date Constructor :

Date(int m, int d, int y) : month(m), day(d), year(y) {
   cout<<"Date constructor.\n";
   }

Address Constructor :

Address(int h, string str, string c, string st, int z) : house(h), street(str), city(c), state(st), zip(z) {
   cout<<"Address constructor.\n";
   }

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Menu.cpp isn't working. C++  utilize inheritance to create a banking app. The architecture of the app is...
Menu.cpp isn't working. C++  utilize inheritance to create a banking app. The architecture of the app is up to you as long as you implement some form of inheritance. Below is my code however the credit and the actual menu isn't working. Can i get some help on getting the menu to work properly. // BankAccount.h #ifndef ACCOUNT_H #define ACCOUNT_H #include <string> #include <iostream> using namespace std; class BankAccount { protected : int noOfWithdrawls; private: // Declaring variables    float balance;...
C++ question. Please explain the code and how it resulted in the output. Explain each line...
C++ question. Please explain the code and how it resulted in the output. Explain each line along with the aspects of "buffers" if possible. Everything is listed below. Code below: #include <iostream> #include <string> using namespace std; int main() {    cout << boolalpha;    cout << static_cast<bool>(1) << endl;    cout << static_cast<bool>(0) << endl;    string s = "AAARGH!!!";    if (s.find("AAA")) { cout << 1 << endl; }    if (s.find("RGH")) { cout << 2 << endl;...
This code it's not working, fix it for me please #include <iostream> using namespace std; class...
This code it's not working, fix it for me please #include <iostream> using namespace std; class People {    string name;    double height; public:    void setName(string name)    {        this->name = name;    }    void setHeight(double height)    {        this->height = height;    }    double getHeight() {        return height;    }    string getName()    {        return name;    } }; int main() {    const int size...
In main.cpp, write a templated function more which takes in two variables of the same type...
In main.cpp, write a templated function more which takes in two variables of the same type and returns whichever variable is greater than (>) the other. You can and may need to add something to the food class in order for more to be able to be called properly. //food.h #ifndef _FOOD_H #define _FOOD_H #include <iostream> #include <string> using namespace std; class Food { private: string name; int quantity; public: Food(); void setName(string newName); void setQuantity(int newQuantity); string getName(); int...
Trying to pass a pointer through the function bool CustomerList::updateStore() that will allow me to modify...
Trying to pass a pointer through the function bool CustomerList::updateStore() that will allow me to modify an input. Ex. (1234, "Name", "Street Address", "City", "State", "Zip") Using the function bool CustomerList::updateStore() Updating..successful New Address: (0001, "Store", "111 Main St.", "Townsville", "GA", "67893") CustomerList.h #pragma once; #include #include "Store.h" class CustomerList {    public:        Store *m_pHead;        CustomerList();        ~CustomerList();        bool addStore(Store *s);        Store *removeStore(int ID);        Store *getStore(int ID);       ...
/* Write a function that looks for a particular person in their respective linked list The...
/* Write a function that looks for a particular person in their respective linked list The only place you need to write code is the "find" method in the linked list class */ #include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); #define BUFFLEN 10 /* Each "person" is defined by their name, zipcode, and their pet's name. Persons are hashed by their zipcode. */ //---------------------------------------------------------------------------- /* function declarations ------------------------*/ int computeKey(int); void add_to_buffer(string,int,string); void find_in_buffer(int);...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity  ...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity   Code   Description   Project   File   Line   Suppression State Warning   C6385   Reading invalid data from 'DynamicStack': the readable size is '(unsigned int)*28+4' bytes, but '56' bytes may be read.   Here is the C++ code were I'm having the warning. // Sstack.cpp #include "SStack.h" // Constructor SStack::SStack(int cap) : Capacity(cap), used(0) {    DynamicStack = new string[Capacity]; } // Copy Constructor SStack::SStack(const SStack& s) : Capacity(s.Capacity), used(s.used)...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits from base class Account and include an additional data member of type double that represents the fee charged per transaction (transactionFee). Write Checking- Account’s constructor that receives the initial balance, as well as a parameter indicating a transaction fee amount. If transaction fee is less than zero, the transactionFee will be set to zero. Write the chargeFee member function that updates the balance by...
Given numRows and numCols, print a list of all seats in a theater. Rows are numbered,...
Given numRows and numCols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numCols = 3 prints: 1A 1B 1C 2A 2B 2C #include <iostream> using namespace std; int main() { int numRows = 2; int numCols = 3; // Note: You'll need to declare more variables /* Your solution goes here */ cout <<...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...