ladyfafa
ladyfafa

Reputation: 7269

What does this C++ statement mean?

void max_idxs(vector<int> &pidxs){
   vector<fragment *> ids;
   max_ids(ids);

   for(size_t i = 0; i < ids.size(); i++){
    int weight_idx = ids[i]->weight_idx; //Get weight index
   }
}

In this C++ code, what does it mean by int weight_idx = ids[i]->weight_idx;?

What does -> mean?

Thanks!

Upvotes: 2

Views: 466

Answers (1)

Borealid
Borealid

Reputation: 98459

x->y means (*x).y. In other words, "take the address pointed to by x, and get the variable y from the object there". Here, it means it'll get the weight_idx from the fragment pointed to by ids[i].

Upvotes: 17

Related Questions