Thread: passing cin

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    2

    passing cin

    Will someone give me an example of how to pass cin as a parameter in a function.

    I am learning about classes and my instructor gave an example that included.

    Money a, b, c;

    a.Input(cin);

    I don't know how to set up the prototype to use this.

    Thanks for your help.
    dwygal

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Unless I'm seriously mistaken std::cin is an std::istream, so:
    Code:
    void Input(std::istream& Stream)
    {
      Stream >> Something;
    }
    
    Input(std::cin);
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newb Question on Passing Objects as Parameters
    By Mariano L Gappa in forum C++ Programming
    Replies: 12
    Last Post: 11-29-2006, 01:08 PM
  2. getline(function)??
    By dac in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2006, 12:42 PM
  3. Passing by reference not always the best
    By franziss in forum C++ Programming
    Replies: 3
    Last Post: 10-26-2005, 07:08 PM
  4. Overriding Cin with Cout
    By Tainted in forum C++ Programming
    Replies: 5
    Last Post: 10-06-2005, 02:57 PM
  5. passing by address vs passing by reference
    By lambs4 in forum C++ Programming
    Replies: 16
    Last Post: 01-09-2003, 01:25 AM