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) { ...... }
【bug总结】缺少模板参数列表
最新推荐文章于 2024-04-07 09:25:25 发布