【发布时间】:2017-03-20 08:41:04
【问题描述】:
我不确定我在哪里做错了。我正在尝试将字符串名称和密钥从类包装传递给类 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;
}
【问题讨论】:
标签: c++ class templates hashtable