method output

Dec 3, 2015 at 4:12pm
Hi, in my assignment I need to output a boarding pass in a format:

FROM DATE TIME
<flight1.departureAirport> <departDate.printDate()> <departTime.printTime()>

TO
<flight1.arrivalAirport> <arrivalDate.printDate()> <arrivalTime.printTime()>


TOTAL TIME: <flight1.arrivalTime - flight1.departureTime>


departure and arrival airport are strings and and i have no problem with outputting it where I want it. But dates and times come form methods like this:

1
2
  void printTime () {
    cout << setw(2) << setfill('0') << hours << ":" << setw(2) << minutes << setfill(' ') << endl;};


 
  void printDate () {cout << setw(2) << setfill('0') << day << "/" << setw(2) << month << "/" << year << endl;};


So when I say
cout << endl << departureAirport << " " ; departureDate.printDate (); cout << " "; departureTime.printTime () ;

departure time comes to a second line.

Is there any way to control where it is outputted. Or any other ideas how to fix it?
Dec 3, 2015 at 4:41pm
If you want all the output on the same line you'll need to remove the endl statements inside your functions.
Dec 3, 2015 at 7:01pm
i feel so incredibly silly, thanks
Topic archived. No new replies allowed.