C++ 错误代码 C1004

标签 c++ visual-studio-2010 compiler-errors

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

“ fatal error 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;
    };

}

最佳答案

类定义必须以分号结尾:

class HashTable {

    // ...

};

关于C++ 错误代码 C1004,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9900470/

相关文章:

c++ - 对音频信号进行编码是否有任何限制?

c# - WebClient 抛出 "No Data Available for Encoding 1252"

java - 用户定义的包和系统定义的java包在访问静态内容方面有什么区别

compiler-errors - 在 Xcode 7 Beta 2 上为架构 'com.apple.compilers.llvm.clang.1_0' 选择了不受支持的编译器 'x86_64'

c++ - seekg 无法正确处理 4294967295 字节的文件

compiler-errors - 德尔福 XE 2010 : Access Violation - How to remove package or component?

c++ - 用指向自定义类的指针填充数组。 C++

c++ - 使用 libpng 提取像素值

c++ - 如何获取远程服务器上的可访问命名管道列表?

c# - Windows 应用程序在调试时不会崩溃,否则会崩溃