声明“ operator()”为无效

时间:2018-09-03 15:12:25

标签: c++ templates

我正在努力修复和理解编译器报告为错误的简单代码,该代码应为Klass定义调用运算符:

template<typename T>
class Klass{
    T operator(){ return T; }
};

g ++ 7.3报告:

a.cpp:3:26: error: declaration of ‘operator()’ as non-function
  T operator(){ return T; }
                          ^
a.cpp:3:26: error: expected ‘;’ at end of member declaration

怎么了?

0 个答案:

没有答案