0

I have a function that receives a vector and passes it to another function. However, when the second function tries to use it, the vector seems to have lost its values.

void getTeam(const vector<uint64_t> &team){ // also try to use team (no reference)
  for (uint64_t id : team){
    //id always equals to 0
  }
}

void gather(const vector<uint64_t> team){
  //receives the correct vector
  auto c_team = getTeam(team);    
}

If I try to add the for loop inside the getTeam function it works fine.

void gather(const vector<uint64_t> team){
  for (uint64_t id : team){
    //return the correct ids
  } 
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.