c++ command similar to setw?

I have the code

ostream& operator<<(ostream& ofile, const Date& d)
{
if(d.day==0 || d.month==0 || d.year==0)
ofile<<"Invalid Date";
else
ofile<<d.month<<"/"<<d.day<<"/"<<d.year;

return ofile;
}

in a Date class where the ostream operator is overloaded.
d.month, d.day, and d.year are of type int
Then I have the code

ostream & operator<<(ostream & ofile, const BookBorrowed& book)
{
ofile<<setw(15)<<book.isbn<<setw(20)<<book.lastName
<<setw(15)<<book.dateDue<<setw(15)<<book.dateBorrowed;

return ofile;
}

in a BookBorrowed class where the ostream operator is overloaded.
book.isbn and book.lastName are type string
book.dateDue and book.dateBorrowed are objects of class Date.

The problem is that when I do the command ofile<<book in main it only uses the setw on the d.month, rather than the entire ostream of Date.
For example,

(15 spaces)(20 spaces)(13 spaces)10/23/2009(13 spaces)10/30/2009

I was wondering if there is a command similar to setw that would allow me to print out the entire Date output within the 15 spaces. If not, I wonder if there is some way of combining the Date data so that it could be outputted as one "string," but I'd rather not do any conversion.
You could probably put all the data into a stringstream first, then use setw() on the single stringstream.
Topic archived. No new replies allowed.