classes

Are there any reasons you would want to avoid writing statements in a class member function that use cout or cin?

Well there is really nothing to stop you from using those statements, but do keep in mind that means the user of that class would automatically have the iostream library included and maybe they don't want that overhaul. That's the only somewhat non-silly reason I can com up with.
cout and cin are global variables and using them in a member function goes against the OOP paradigm. You should let the user pass the ostream or istream to the function as a parameter... (But only if you really care about staying true to OOP :)
Last edited on
Topic archived. No new replies allowed.