C++错误代码C1004

C++ Error Code C1004

本文关键字:C1004 错误代码 C++      更新时间:2023-10-16

我正试图用C++编写一个类,但每当我尝试编译时,它都会失败,并出现以下错误:

"致命错误C1004:发现意外的文件结尾"

我正在使用VS2010。Microsoft文档(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;
    };
}

类定义必须以分号结尾:

class HashTable {
    // ...
};