-2

Can some lovely soul help me out with this one :) Could you please explain each piece of this line of code and what each Individual piece does? Thank you in advance.

istream & operator >>( istream & input, Registration & R )

ostream & operator <<( ostream & os, const Registration & R )
Tim Ogilvy
  • 1,774
  • 1
  • 21
  • 33
Eli Carter
  • 11
  • 1
  • 1
    You could try to look into some tutorials, http://www.tutorialspoint.com/cplusplus/cpp_basic_input_output.htm for example. – pingul Mar 31 '16 at 02:41
  • 4
    I'm fairly certain that if a full, detailed, keyword-by-keyword, explanation is given, it's not going to answer your real question, and you're unlikely to learn anything. – Sam Varshavchik Mar 31 '16 at 02:41
  • Stream operators usually perform input and output, although you haven't provided the definition of either of them so as far as we know they could be launching missions to the moon or feeding your cat. – user657267 Mar 31 '16 at 02:41
  • You need to ask a more specific question. If you know C++ syntax, you should be able to understand the general idea of what it's doing. But some part of it is confusing you, so ask about that part. – Barmar Mar 31 '16 at 02:44

1 Answers1

3

istream & operator >>( istream & input, Registration & R )

istream& means that object of type istream will be returned by reference.

operator>> is the identifier of the function, it is specifically named so that it overrides the default functionality of the >> operator (similar to how you can override the default functionality the + operator, or operator+() as a "binary" (meaning two) operator (meaning it involves two arguments).

(...) everything within the parentheses are the parameters of the function, they are the data that will be given to the function when it is called to be run.

istream& input indicates that a variable called "input" of type istream will be passed in by reference, meaning that usage of the input variable will refer to the original variable passed in from the location in which it was called and NOT a copy (see: passing by reference and passing by value).

Registration& R indicates that a variable called "R" of type Registration will be passed in by reference (see the definition above). The type Registration seems to be derived from some method for defining a type, such as from a class or a struct.

If you're looking for more information on what an object of type istream is, how it's defined, or what "it does," (along with anything else I mentioned here) I recommend running a search and looking through the wealth of free, available information online.

Sean Pianka
  • 1,660
  • 1
  • 20
  • 37