Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Quick Question

42 views
Skip to first unread message

Doug Mika

unread,
Apr 20, 2015, 11:56:20 AM4/20/15
to
The official definition of cin.get(cStr, n) is as follows:

std::istream::get
istream& get (char* s, streamsize n);

Does this mean that when we type
char someString[256];
cin.get(someString, 255);

we ignore the return type istream&?
Does this mean I could write:
cin = cin.get(someString,255);
What purpose does this return type serve?

Victor Bazarov

unread,
Apr 20, 2015, 12:16:40 PM4/20/15
to
The purpose is to allow chaining of function calls, like

cin.get(blah).get(blahblah)

or using it in an expression

cin.get(blah) >> somethingelse;

V
--
I do not respond to top-posted replies, please don't ask

Paavo Helde

unread,
Apr 20, 2015, 12:21:27 PM4/20/15
to
Doug Mika <doug...@gmail.com> wrote in news:2cab1a66-64b1-4b2f-b46d-
1b9d2d...@googlegroups.com:
This allows for call chaining, e.g.

cin.get(string1, 255).get(string2, 255).get(string3, 255);

Message has been deleted
Message has been deleted
0 new messages