C++ C++;类-如何从函数返回自定义类型的向量?

C++ C++;类-如何从函数返回自定义类型的向量?,c++,class,vector,declaration,C++,Class,Vector,Declaration,当我想让一个函数返回我刚刚定义的struct类型的向量时,我在类中设置函数时遇到了问题。编译器出现“使用未声明的标识符”错误 在.h文件中:(未给出错误) struct工作点; 公众: 向量CalculateWorkingPointCloud(); 在.cpp文件中: struct DeltaKinematics::workingPoint { int x, y, z; //more stuff to come }; vector<workingPoint> De

当我想让一个函数返回我刚刚定义的
struct
类型的向量时,我在类中设置函数时遇到了问题。编译器出现“使用未声明的标识符”错误

在.h文件中:(未给出错误)

struct工作点;
公众:
向量CalculateWorkingPointCloud();
在.cpp文件中:

struct DeltaKinematics::workingPoint {
    int x, y, z;
    //more stuff to come
};

vector<workingPoint> DeltaKinematics::calculateWorkingPointCloud(){ //error here is "Use of undeclared identifier 'workingPoint'

}
结构Deltakinetics::工作点{ int x,y,z; //还有更多的东西要来 }; vector Deltakinetics::calculateWorkingPointCloud(){//这里的错误是“使用未声明的标识符'workingPoint' }
编译器似乎不知道什么是
工作点,尽管它是在函数之前声明的。

您定义了一个结构
Deltakinetics::workingPoint
,然后试图返回一个结构
工作点
。您需要明确的限定。

这只是一个looku的问题p、 您需要完全限定名称,例如
向量Deltakinetics::calculateWorkingPointCloud(){…


关于这个问题,我问了一个类似的问题。也许这对你来说也很有趣。

谢谢你的回答:),这是一个很好的完整答案,内容非常丰富。@DeadMG和@mkaes都解决了我的问题。在阅读了@mkaes问题的答案后,我还将结构声明移到了标题中,这似乎是最好的练习。希望这对某人有帮助:)
struct DeltaKinematics::workingPoint {
    int x, y, z;
    //more stuff to come
};

vector<workingPoint> DeltaKinematics::calculateWorkingPointCloud(){ //error here is "Use of undeclared identifier 'workingPoint'

}