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;...
15.4 Zip code and population (class templates) Complete the TODOs in StatePair.h and main.cpp. StatePair.h Define...
15.4 Zip code and population (class templates) Complete the TODOs in StatePair.h and main.cpp. StatePair.h Define a class StatePair with two template types (T1 and T2), and constructor, mutators, accessors, and PrintInfo() member functions which will work correctly with main.cpp. Note, the three vectors (shown below) have been pre-filled with StatePair data in main() and do not require modification. vector<StatePair <int, string>> zipCodeState: ZIP code - state abbreviation pairs vector<StatePair<string, string>> abbrevState: state abbreviation - state name pairs vector<StatePair<string, int>>...
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;...
Utilize the code from last week Add a default, full, and copy constructor. Also add a...
Utilize the code from last week Add a default, full, and copy constructor. Also add a constructor that allows you to specify only the name of the video game with no high score or times played specified. Adjust your code to demonstrate use of all 4 constructors and output of the resulting objects. #include <iostream> #include <string> #include <iomanip> using namespace std; class VideoGame { private:     string name;     int highScore;     int numOfPlays; public:     VideoGame() {        ...
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...
c++ Language Fix this code to have it concatenate two strings st1 and st2 and put...
c++ Language Fix this code to have it concatenate two strings st1 and st2 and put the result in st3 with a space separator. it has to be done using array representation of strings #include <iostream> using namespace std; #include <string> int main() { string st1,st2, st3; int c = 0, i =0;    cout << "Enter a string: "; cin >> st1; cout << "Enter another string: "; cin >> st2;    while (st1[c] != '\0'){ st3[c] = st1[c];...
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);       ...
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...
do (iii) and (iv) (i) This is a simple Point class interface file whose objects represent...
do (iii) and (iv) (i) This is a simple Point class interface file whose objects represent points in the cartesian plane #include <iostream> using namespace std; class Point { public:     Point()      // default constructor         Point(double x, double y); // another constructor         double x() const; // get function, return _x         double y() const; // get function, return _y private:         double _x, _y; }; (ii) Here is a test driver file for the Point class...
/* 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);...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT