My teacher wanted us to learn the ifstream class and how it works. She gave us homework to create a FileStream wrapper class that is templated to work with anything and can take in anything that's in the file.
I have written everything except I can't get it to compile because I don't know how to write the >>
operator and keep getting errors for it. This is what I have so far:
template<class A>
ifstream& operator >>(FileStream<A> fs, A& x){
fs>>x;
return fs;
}
In the main she is using to check our work it is called like this:
FileStream<Word> input;
Word temp; //word is a class we created to manipulate strings in certain ways
while(input>> temp){
cout<<temp<<endl;
}
If anyone could help me out I would be most grateful. I've been working on this for 2 days and I can't get it.