Is var << ifstream the same as ifstream >> var?
As far as I can tell, they should be exactly the same. But it’s late and my brain is half-asleep, so I would like a clarification.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They’re not the same.
foo << barisfoo.operator<<(bar)oroperator<<(foo, bar), whilebar >> fooisbar.operator>>(foo)oroperator>>(bar, foo).They’re just different things. Whether any of those versions exist, let alone whether if two versions exist they do the same thing, is entirely dependent on what’s in your code.
For the standard iostreams, typically only the following two free functions, and no others, are defined for some user-defined type
T: