我正在尝试用C ++编写一个类,但每当我尝试编译时,它都会因为这个错误而失败:
“致命错误C1004:发现意外的文件结尾”
我正在使用VS2010。微软的文档(http://msdn.microsoft.com/en-us/library/4exw7xyc(v = vs.80).aspx)说这个错误是由于缺少右括号,分号等引起的。但我可以看到从代码突出显示所有大括号匹配,我相信如果你错过了分号,你会收到通知。
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;
};
}
答案 0 :(得分:2)
类定义必须以分号结尾:
class HashTable {
// ...
};