// CS2310 Exercise 10 // (Implementation file address.cpp) // // Name ___________________________ // // Chapter 14, p822 - 3, 4, 5 // // The following class represents a person's mailing // address in the United States. Using inheritance, we // want to derive an international address class, // InterAddress, from the Address class. For this // exercise, an international address has all the // attributes of a U.S. address plus a country code // (a string indicating the name of the country). The // public operations of InterAddress are Write (which // reimplements the Write function inherited from // Address) and a class constructor that receives // five parameters (street, city, state, zip code, // and country code). Write a class declaration for // the InterAddress class. // // Implement the InterAddress class constructor // // Implement the Write function of the InterAddress // class. #include #include #include "address.h" using namespace std; void Address::Write() const { cout << "The address is:" << endl; cout << street << ", " << city << ", " << state << ", " << zipCode << endl; } Address::Address(/* in */ string newStreet, /* in */ string newCity, /* in */ string newState, /* in */ string newZip ) { street = newStreet; city = newCity; state = newState; zipCode = newZip; } void InterAddress::Write() const { // Write the code for Write function of InterAddress // class here. It calls the Write function of the base // class Address to print out the street number, city // name, state name and zip code. And then print out // the country code in the second line. } InterAddress::InterAddress(/* in */ string newStreet, /* in */ string newCity, /* in */ string newState, /* in */ string newZip, /* in */ string newCountry) : // Write the missing code here: Initialize the private // data members of the base class by passing the first // four parameters to the constructor of the base // class. { // Write the missing code here: Initialize the // "country" private variable using the passed in // parameter "newCountry". } int main() { InterAddress interAddr1("One Main St.", "Houston", "TX", "77002", "USA"); InterAddress interAddr2("35042 Campus de Beaulieu", "Rennes", "Cedex", "35042", "France"); interAddr1.Write(); interAddr2.Write(); return 0; }