【发布时间】:2011-04-28 17:29:26
【问题描述】:
我的代码有什么问题?
template<int E, int F>
class Float
{
friend Float<E, F> operator+ (const Float<E, F> &lhs, const Float<E, F> &rhs);
};
G++ 只是不断警告:
float.h:7: warning: friend declaration ‘Float<E, F> operator+(const Float<E, F>&, const Float<E, F>&)’ declares a non-template function
float.h:7: warning: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) -Wno-non-template-friend disables this warning
我尝试add <> after the function name here,如警告说明中所述,但 g++ 给了我一个错误。
我用clang++编译了代码,很好,一点警告都没有。
【问题讨论】:
标签: c++ templates operator-overloading friend