Thread: "istream" Help

  1. #1
    Registered User
    Join Date
    Nov 2002

    "istream" Help

    I know the concepts behind "fstream", like ifstream and ofstream, but what exactly is istream? For example, say there is a function with this heading:

    void ChangePrices(GroceryStore &store, istream &input);
    // Precondition: Input is open for reading.
    //                       Each line consists of a valid one word item name
    //                       and a valid price.
    // Postcondition: Changes the prices of items in store using names
    //                        and new prices from input.
    What does that &input variable hold exactly? Can someone assist me with some examples? Thanks.

  2. #2
    Registered User
    Join Date
    Mar 2002
    cin is a predeclared example of an istream, but you can declare others if you wish. I've not done it, but I suspect you could use an istream to get data from a port other than the one the keyboard is on, say data being downloaded from the internet, or maybe from a satellite, something other than a file per se'.

    I believe fstreams are derived from istreamsa and ostreams. Therefore fstreams and ifstreams are all examples of istreams, too.

Popular pages Recent additions subscribe to a feed