编译器错误:"使用"之前应为非限定 id

Compiler error: 'expected unqualified-id before "using'''

本文关键字:id 错误 使用 编译器      更新时间:2023-10-16

这是我的代码:

    //test file
    #include <iostream>
    #include "stat.h"
    #include "frequency.h"
    using namespace std;
    int main(){
      cout << "helo"<< endl;
      return 0;
    }

当我尝试编译时,我得到:

    test.cc:7: error: expected unqualified-id before "using"
    test.cc:7: error: expected `,' or `;' before "using"

知道这里发生了什么吗?

您可能错过了;在头文件的末尾。

它应该是这样的:

 class frequency {
      ...
 };

问题可能是frequency.h最后一行中的错误。