1

您好我收到以下错误

templateatt.cpp:4:32: error: expected template-name before ‘<‘ token
templateatt.cpp:4:32: error: expected â{â before ‘<‘ token
templateatt.cpp:4:32: error: expected unqualified-id before ‘<‘ token

当我编译以下 cpp 文件时:

    #include<iostream>

    template <class R, class T>
    class mem_fun_t: unary_function<T*, R> {
      R (T::*pmf)();
    public:
      explicit mem_fun_t(R (T::*p)()):pmf(p){}
      R operator() (T *p) const { return (p->*pmf()); }
    };

    int main() {
      return 0;
    }

任何帮助都会很棒。我坚持这一点。

4

1 回答 1

7

不要忘记#include <functional>获取unary_function,然后使用std::unary_function.

于 2013-04-10T11:10:49.463 回答