[英]error: ‘class std::vector<route, std::allocator<route> >’ has no member named ‘exitPoint’
Please tell me if some more info is needed here: Global declarations:请告诉我这里是否需要更多信息:全局声明:
typedef struct route
{
int exitPoint;
bool allBranchesTraversed;
} route;
****vector <route> routeVector;****
The culprit func is getting called from:罪魁祸首 func 从以下位置调用:
int main ()
{
....
do
{
****currentExitPoint = returnShortestWeightedBranch (&routeVector);****
if (currentExitPoint != -1)
{
objRoute.exitPoint = currentExitPoint;
routeVector.push_back (objRoute);
}
else
{
break;
}
} while (1);
}
The error is in this func on the line with ** :错误在**行的这个函数中:
int returnShortestWeightedBranch (vector <route> *objRouteVector)
{
....
for (unsigned int h = 0; h < objRouteVector->size (); h++)
{
// Locate 'currentExitPoint' in the vector 'exitPointDetailsVector'.
for (i = 0; i < exitPointDetailsVector.size(); i++)
{
// If located
****if (objRouteVector[h].exitPoint == exitPointDetailsVector[i].exitPoint)****
{
// For all the branches of the 'currentExitPoint',
for (j = 0; j < exitPointDetailsVector[i].branchesVector.size(); j++)
{
...............
}
If you use vector <route> *objRouteVector
as parameter, you need (*objRouteVector)[h].exitPoint
.如果你使用vector <route> *objRouteVector
作为参数,你需要(*objRouteVector)[h].exitPoint
。 Better is using reference: vector <route> &objRouteVector
.更好的是使用参考: vector <route> &objRouteVector
。
You took a pointer to objRouteVector, you need to take a reference.你拿了一个指向 objRouteVector 的指针,你需要拿一个引用。 Your code indexing objRouteVector isn't indexing the vector at all- it's indexing the pointer .您的代码索引 objRouteVector 根本没有索引向量 - 它正在索引指针。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.