gcc无法在命名空间中编译静态函数

Tho*_*mas 3 c++ namespaces g++

我有以下声明.

namespace test{
static cl_option* find_opt(const int &val, const cl_option *options);
}

test::cl_option* test::find_opt(const int &val, cl_option *options){}
Run Code Online (Sandbox Code Playgroud)

问题是编译时我得到以下错误.

error: ‘test::cl_option* test::find_opt(const int&, test::cl_option*)’ should have been declared inside ‘test’
Run Code Online (Sandbox Code Playgroud)

提前致谢

Ern*_*ill 6

您声明的函数与您尝试定义的函数不同:第二个参数在声明中是"const",而不是在定义中.这是两个不同的功能.