Question: Implement a class Address. An address has a house number, a street, an optional apartment number, a city, a state, and a postal code. Supply

Implement a class Address. An address has a house number, a street, an optional apartment number, a city, a state, and a postal code. Supply two constructors: one address with an apartment number and one address without the apartment number. Supply a print function that prints the address with the house number, street name, optional apartment number on one line and the city, state, and postal code on the next line. Overload an operator less than that tests whether one address comes before another when the two addresses are compared by postal code.

house_number is an integer; street is a string; apartment_number is an integer; city is a string; state is a string; postal_code is a string; 

Please create the following files and upload to Zybooks. Address.h Address.cpp main.cpp Use Address as your class name Use main.cpp as your test program and write the following tests.

  1. create an address without the apartment number.
  2. create another address with the apartment number.
  3. Use the print function to print out the addresses that you just create in your main.cpp. Use the information in below to create your addresses:
Comparing address 148 First Ave San Diego, CA, 10392 with address 553 Second St, #44 San Diego, CA, 10394 The first address comes before the second 
  1. Use a less than operator to compare two address. If the first address' zip code is less than the second address' zip code, then print The first address comes before the second otherwise, print The first address comes after the second

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!