It might help if I specify I am attempting to output information stored in a struct, which is also stored in a pointer-based array.
I'll post the sections of code where I imagine the problems are occurring along with my output (hopefully the formatting does not get messed up in the post)
Here's the first portion of the output to get an idea:
Code:
Origin Destination Flight Price
=================================================
From Chicago to: Albuquerque 380 $400
Atlanta 290 $175
Miami 2843 $500
Orlando 3940 $430
From Nashville to: Atlanta 339 $83
Denver 1203 $560
Las-Vegas 920 $59
Miami 89 $490
New-York-City 983 $260
Philadelphia 8831 $410
Tampa 665 $320
Tampa 428 $79
In a file named type.cpp
Code:
ostream& operator << (ostream& os, const flightStruct rhs) //Overloaded operator for '<<'{ //for struct output
//for origin
os << fixed << setw(10) << rhs.destination //for destination
<< setw(7) << rhs.flightNum << setw(10) //for flight number
<< setw(8) << "$" << rhs.price << endl; //for flight price
return os;
}
In a file name flightMap.cpp:
Code:
void flightMap::displayFlightInfo() const //Displays the origin, destination, flight number, and price of each flight{
for(int index = 0; index < size; index++) //Set index to zero, check to see if it is less than the amount of cities read in, increment index
{
if(flights[index].length() > 0) //If the flight contains information
{
cout << "From " << cities[index] << " to: "; //Output the flight
flights[index].Display();
}
}
}
In the main.cc file:
Code:
cout << " " << "Origin" << '\t' << " Destination" << '\t' << "Flight" << " " << "Price" << '\t' << endl << "=================================================" << endl;
map.displayFlightInfo(); //Display the flight information