Thread: istream??

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    20

    istream??

    when i pass istream to a class function how do i use the istream that is sent?

    This is what i am trying but i don't know how to use the in

    Code:
    void class::readinBalance (istream & in)
    {
      in>>var;
    
      return;
    }
    Thanks for the help

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    if var is a private member of your class ( and i take it that keyword is just a placeholder) then thats fine. btw you sdont need the return; at the end of a function that returns void. Only if you are returning from the middle of the func do you need that. i.e.
    void func()
    {
    if(something) return;
    else
    {
    //do $$$$
    }
    }
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    That should work fine (did for me), just make a variable named var.
    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.

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    20

    thanks

    thanks I'm good now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. istream
    By Beowolf in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2007, 05:11 PM
  2. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  3. istream overload
    By Trauts in forum C++ Programming
    Replies: 6
    Last Post: 05-06-2003, 08:29 PM
  4. istream >> overloading
    By wazza13 in forum C++ Programming
    Replies: 1
    Last Post: 05-03-2002, 10:56 PM
  5. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 04:07 PM