class Destination
{
....
private:
CityNameType city; // name of the city where the packages are sent
int package_count; // count of packages
float total_weight; // weight of all packages for this city
float packageWeightSum; // total weight of all packages
int packageCountSum; // total count of all packages
public:
// print out the fields of the destination, appropriately labeled and formatted.
void PrintDest( DestinationList & destB ) const
{
destB.PrintCityName(true);
cout << setw(4) << right << package_count << right
<< " packages weighing" << setw(11) << right << total_weight
<< right << " pounds";
}
class DestinationList
{
private:
int num; // number of objects in the list
Destination list[MAX_CITIES]; // array of destinations
public:
// Method to print city in uppercase. The parameter rightjustify is
// set to true when used to print in table form. Table form means
// the name is right justified when printed. The parameter is
// set to false when used to print in messages.
// params: IN
void PrintCityName( bool rightjustify ) const
{
CityNameType ucity;
strcpy(ucity, city);
ToUpper(ucity);
{
cout << setw(19) << right << ucity;
}
else
cout << city;
}
//
void Summarize( )
{
for (int i = 0; i < num; i++)
{
list[i].PrintDest();
cout << endl;
}
}
I'm having trouble calling PrintCityName from PrintDest, the problem is that they are in 2 different classes, yet this has to be because of the private variables needed from both classes.
The idea is that PrintCityName converts a city name into uppercase, which is used inside of the PrintDest function to print a single line of info. Then, the Summarize function loops, printing out a line for each city in the list.
How do I call PrintCityName in the other class function?