【bug总结】缺少模板参数列表
template<typename T>class Set {T arr[maxn];int p_arr = -1;public://......Set interSet(const Set&);Set unionSet(const Set&);//......};template<typename T>Set Set<T>::interSet(
·
template<typename T>
class Set {
T arr[maxn];
int p_arr = -1;
public:
//......
Set interSet(const Set&);
Set unionSet(const Set&);
//......
};
template<typename T>
Set Set<T>::interSet(const Set& c) { ...... } //bug!
template<typename T>
Set Set<T>::unionSet(const Set& c) { ...... } //bug!
//出现错误提示:缺少模板参数列表
//分析:模板类是带参数的类,要求在接口实现中的类名称后面加入模板类参数,函数返回值亦如此
//正确写法:
template<typename T>
Set<T> Set<T>::interSet(const Set& c) { ...... }
template<typename T>
Set<T> Set<T>::unionSet(const Set& c) { ...... }
更多推荐
所有评论(0)