小编fab*_*omf的帖子

static方法不能返回struct类型?(C++)

我想知道这里做错了什么:

class Grasp
{
    typedef struct
    {
        int unique;
        int intersection;
        int sets;
        float alpha;
        int *covered;
        int *choosen;
    }best;
    static best findSolution();
}
Run Code Online (Sandbox Code Playgroud)

在.cpp上:

best Grasp::findSolution()
{
    //it doesn't matter
}
Run Code Online (Sandbox Code Playgroud)

该行有一个错误:最好的 Grasp :: findSolution()

' best '没有命名类型

为什么?

c++ methods static struct return

2
推荐指数
1
解决办法
540
查看次数

标签 统计

c++ ×1

methods ×1

return ×1

static ×1

struct ×1