我想在包含头类的某些文件中包含一个简单的哈希表类。但是每当我尝试编译时,我会得到如下几个错误:Visual C++链接器错误2019
LNK2019:无法解析的外部符号“public:__thiscall HashTable ::〜HashTable(void)”(?? 1HashTable @@ QAE @ XZ)
我正在使用Visual Studio 2010.我知道这意味着它无法在任何源文件中找到函数定义但我已经将它们定义在与文件相同的目录中的文件中堪称也许Visual Studio中看起来并不在当前目录中,除非你设置一些链接器选项
这里是源代码:?
//HashTable.h
#ifndef HASH_H
#define HASH_H
class HashTable {
public:
HashTable();
~HashTable();
void AddPair(char* address, int value);
//Self explanatory
int GetValue(char* address);
//Also self-explanatory. If the value doesn't exist it throws "No such address"
};
#endif
//HashTable.cpp
class HashTable {
protected:
int HighValue;
char** AddressTable;
int* Table;
public:
HashTable(){
HighValue = 0;
}
~HashTable(){
delete AddressTable;
delete Table;
}
void AddPair(char* address, int value){
AddressTable[HighValue] = address;
Table[HighValue] = value;
HighValue += 1;
}
int GetValue(char* address){
for (int i = 0; i<HighValue; i++){
if (AddressTable[HighValue] == address) {
return Table[HighValue];
}
}
//If the value doesn't exist throw an exception to the calling program
throw 1;
};
};
[如何创建在C++类(http://www.learn-programming.za.net/programming_cpp_learn10.html) – 2012-03-28 21:03:07