Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this C++ statement mean?

Tags:

c++

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!

like image 567
ladyfafa Avatar asked May 26 '26 17:05

ladyfafa


1 Answers

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

like image 155
Borealid Avatar answered May 30 '26 04:05

Borealid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!