我想知道这里做错了什么:
class Grasp
{
typedef struct
{
int unique;
int intersection;
int sets;
float alpha;
int *covered;
int *choosen;
}best;
static best findSolution();
}在.cpp上:
best Grasp::findSolution()
{
//it doesn't matter
}这一行出现了一个错误:最佳抓取::findS卷积()
‘最佳’没有命名类型
为什么?
发布于 2013-07-15 18:20:31
best是嵌套类型,因为它是Grasp的成员。因此,您需要将返回类型限定为:
Grasp::best Grasp::findSolution()
{
//your code
}注意返回类型。:-)
发布于 2013-07-15 18:21:07
best是包含在Grasp中的类型胡枝子。除非它是全局的,否则编译器无法知道它属于这个类。使用Grasp::best代替:
Grasp::best Grasp::findSolution()
{
// ..
}https://stackoverflow.com/questions/17661062
复制相似问题