1. > How do you pass the_text_file [this is the name of an input file > stream] to a function? I tried > calling it in a function, but the compiler tells me it's not declared. > I tried passing it as a parameter, but I got a whole slew of confusing > error messages about the stream. This is a C++ thing, not an objectcenter bug. First the extremely short answer: On assignment 1, just do your stream I/O inside main, or else define the_text_file as a global variable. Now the slightly longer answer: If you want to pass a stream to a function, you need to either pass a pointer to it or pass it by reference. Normally, I think it's a bad idea to pass by reference (see the end of this message for more on that) but in this case, it makes things a bit cleaner. For instance, you can do: void myfunction(ifstream *p) { word_t w; *p >> w; } and call it with myfunction(&the_text_file); or, you can define myfunction like: void myfunction(ifstream &str) { word_t w; str >> w; } and then call it with myfunction(the_text_file); Now the really long answer: First, what's a stream? Well, a stream is a "class", which is like a struct. It holds inside it a bunch of bookkeeping information about how much you have read in and other pieces of information. If you passed a stream into a function by value, weird things would happen since the function you passed it to would have a COPY of the stream. So, if the function read in a few words and then returned, your original stream wouldn't have its bookkeeping information consistent any more. For this reason, C++ does not allow you to make copies of the stream, and in particular to pass it by value. So, you have to either pass a pointer or a reference. Avrim Blum ps: here is why in general I don't like pass by reference. In C, if you have two ints a and b, and you call foo(a,b), maybe foo will crash your program but at least you can be sure it won't change the values of a and b. In C++, you can't be so sure, since maybe they are "reference" arguments to foo. You need to check the function prototype of foo to be sure. This makes it harder to debug code, since it's easy to forget when you're scanning through the program. ==============================================================================