包括导致预期函数体错误的语句

include statement casuing expected function body error

本文关键字:错误 语句 函数体 包括导      更新时间:2023-10-16

我在xcode中编码C++,以下代码导致"函数分解器之后的预期函数体"错误:

#include <iostream>
#include <iomanip>
#include "Implementation.hpp"
using namespace std;

实施后弹出错误.hpp

这是我的实现.hpp文件:

    #ifndef Implementation_hpp
#define Implementation_hpp
using namespace std;

#include <stdio.h>
int* getLottoPicks(int picks[]);
int genWinNums();
bool noDuplicates(int picks[], int input)
#endif /* Implementation_hpp */

如果有人能找到这个问题,我将不胜感激!提前谢谢。

编译错误来自这里:

bool noDuplicates(int picks[], int input) // ';' or body expected

如果没有;,编译器期望函数体{ /* code */ }到来,而您没有提供。

您有两个选项,其中一个是提供适当的函数体,如下所示:

bool noDuplicates(int picks[], int input)
{
    // Code
}

另一种是声明如下:

bool noDuplicates(int picks[], int input); // note that ';' is used.