istream Operator>> - Implement getline()

Hi everyone!

I am doing an exercise on my book and I wish to implement getline() function in my custom operator >>.

My definition is:

1
2
3
4
5
6
7
8
9
10
11
12
13
istream& operator>>(istream& is, Book& n)
{
	string title, author;
	int day, month, year;
	char check;

	is >> title >> author >> day >> month >> year >> check;
	if (!is) return is;

	n = Book{ title,author,day,month,year,check };

	return is;
}


I could implement getline() for title and author?

Thank you!
I don't know what you mean by "implement", but I guess "use". Of course you can use getline() in a function that reads from stream into a string.
It was what I meant!

Thanks! :)
Topic archived. No new replies allowed.