0
我不确定我做错了什么地方。我attemping从类包装传递字符串名称和关键类hashT使用类模板需要模板参数列表并且没有适当的默认构造函数
C2955:“hashT”:使用类模板需要模板参数列表
C2512:“hashT”:没有适当的默认构造函数可
template<class T>
class hashT{
public:
hashT(const int newKey, const string newName= "") :theList(newKey,newName){
key = newKey;
name = newName;
theList.push_back(key);
theList.push_back(name);
}
hashT & operator=(const hash &rhs) {
if (this != &rhs) {
key = rhs.getKey();
name = rhs.getName();
desc = rhs.getDes();
}
return *this;
}
private:
vector<T>theList;
int key;
string name;
}
类包装
class wrap{
public:
wrap(){ myList = new hashT[1000];
~wrap(){ delete[]myList;}
//getter
hashT<class T> *getHashing() const{
return mylist;
}
//setter
void setNextHash(hashT<class T> *hashelement){
mylist = hashelement;
}
private:
hashT<class T> *mylist;
}
而且不可能像'hashT * mylist;' –
Danh
@Danh Jup那样宣布成员忘记了那个抱歉:)谢谢 – Rakete1111