| Dear Karen,
I had the exact same error message when I was trying to specialise the
istream_iterator<T> class to iterate over ifstreams (ifstream_iterator<T>). I
was trying to instantiate an ifstream_iterator for iterating over objects from
a "line" class (user written) as follows:
string filename("somefile.dat");
ifstream somefile(filename.c_str());
ifstream_iterator<line> start (somefile);
-------------------------^
In the end I decided to use an alternative approach to the ifstream_iterator
one however, I found that just changing the last line to:
ifstream_iterator<line()> start (somefile);
allowed the line to compile, I can only assume its something strange to
do with default ctors, I don't really understand it because ifstream_iterator
was almost exactly the same as istream_iterator, but the first form works for
istream_iterator.
If you find any more details out I'd be interested to know.
Regards,
Brian.
[Posted by WWW Notes gateway]
|
|
Regarding .0 -- Can you supply us with some source code,
that reproduces the problem, i.e. the declaration the template
class camDoublyLinkedList_Template_t? This has to
declared somewhere (i.e. in a header file) before you can use
it to declare the input_list object.
If I create an empty class, there is no problem, i.e.:
// this compiles fine
template <class T>
class camDoublyLinkedList_Template_t {};
camDoublyLinkedList_Template_t<char> input_list;
main() {}
Regarding .1, Can you supply some source code too,
I tried this and it compiles fine with V5.5:
#include <string>
#include <iterator>
#include <fstream.h>
template <class T>
class ifstream_iterator {
public:
ifstream_iterator(const ifstream&) {;}
};
class line {};
int main() {
string filename("somefile.dat");
ifstream somefile(filename.c_str());
ifstream_iterator<line> start (somefile);
return 0;
}
thanks,
Judy
|
| I obtained the full source and found that the header file that contains
the declaration of the template class camDoublyLinkedList_Template_t
does not get compiled on Digital UNIX. When I changed the defines on
the compile line so this header file would get compiled, the problem
does not occur. I've reported this back to CV.
Thanks for your help,
Karen
|