so for the example that i gave before. Just say i had a function called get() which gets the details for a book.
i would have :
Code:
void Book::get(void)
{
ostream bookstream;
cout<<"what is the book's title"<<endl;
write(bookstream);
cout<<"Who is the book's Author"<<endl;
write(bookstream);
read(bookstream); //can i pass an ostream as an i stream?? how can i do this?
etc...
}
And write would be:
Code:
ostream&Book::write(ostream&out)
{
out<<cin;
}
And then read would be:
Code:
istream&Book::read(istream&in)
{
in>>title;
in>>author;
}
Is this right?? If it is, I don't see why streaming should be used. Whats wrong with just asking the user for the title then storing it straight away?