简体   繁体   English

错误:'类 std::vector <route, std::allocator<route> &gt;' 没有名为“exitPoint”的成员</route,>

[英]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.

相关问题 错误:&#39;类 std::vector<Shape*> &#39; 没有名为 &#39;sort&#39; 的成员 - error: ‘class std::vector<Shape*>’ has no member named ‘sort’ 致命错误:“std::vector”中没有名为“find”的成员<int, std::allocator<int> &gt;'</int,> - fatal error: no member named 'find' in 'std::vector<int, std::allocator<int> >' C ++编译器:'class std :: vector <std :: vector <char >>>'没有名为'emplace_back'的成员 - C++ compiler: 'class std::vector<std::vector<char> >' has no member named 'emplace_back' g++:'类标准::map <int, std::vector<std::vector<int> &gt; &gt;' 没有名为 'insert_or_assign' 的成员</int,> - g++: 'class std::map<int, std::vector<std::vector<int> > >' has no member named 'insert_or_assign' 错误:“类std :: stack &lt;&gt;”没有名为“ pop_back”的成员 - error: 'class std::stack<>' has no member named 'pop_back' std :: array错误:没有名为&#39;assign&#39;的成员 - std::array error: Has no member named 'assign' 错误:&#39;类 std::unique_ptr <std::set<long unsigned int> &gt;&#39; 没有名为 &#39;size&#39; 的成员 - error: 'class std::unique_ptr<std::set<long unsigned int> >' has no member named 'size' flann / util / serialization.h类std :: unordered_map <unsigned int, std::vector<unsigned int> &gt;&#39;没有名为&#39;serialize&#39;的成员 - flann/util/serialization.h class std::unordered_map<unsigned int, std::vector<unsigned int> >' has no member named 'serialize' “的std ::矢量 <double> :: iterator&#39;没有名为&#39;begin&#39;的成员 - 'std::vector<double>::iterator' has no member named 'begin' std :: vector中的自定义分配器 - Custom allocator in std::vector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM