我一直在尝试编译下面的代码,但显示错误。我不确定它期望的模板名称。我对此很陌生,这是一个非常古老的代码,正在新的 g++ 编译器上编译。有人可以帮忙吗?
在此先感谢,不胜感激。
错误:
./dir.h:12: error: expected template-name before â<â token
./dir.h:12: error: expected â{â before â<â token
./dir.h:12: error: expected unqualified-id before â<â token
make: *** exit code 1 making Life.o
代码:
#if !defined(DIRECTORY_H)
#define DIRECTORY_H
#include <string>
#include <algorithm>
#include <iterator>
//using std::input_iterator;
using std::string;
struct dir_it_rep;
class dir_it : public input_iterator<string,int> //<------- Line 12
{
public:
dir_it(); // "past the end" ctor
explicit dir_it(string const &); // the "normal" ctor
dir_it(dir_it const &it);
~dir_it();
dir_it &operator= (dir_it const &it);
string operator* () const { return i_value; }
dir_it &operator++ ();
dir_it operator++ (int) { dir_it rc (*this); operator++(); return rc; }
bool operator== (dir_it const &it) const;
bool operator!= (dir_it const &it) const { return !operator== (it); }
private:
dir_it_rep *i_rep; // representation for the next value
string i_value; // the current value
};
#endif /* DIRECTORY_H */