Skip to content

Instantly share code, notes, and snippets.

@LimHyungTae
Created January 13, 2020 04:08
Show Gist options
  • Save LimHyungTae/1ad23e70bc5488e23ed81df52d7ad3aa to your computer and use it in GitHub Desktop.
Save LimHyungTae/1ad23e70bc5488e23ed81df52d7ad3aa to your computer and use it in GitHub Desktop.
#include <iostream>
vector<float> ints = {0.01, 0.02, 0.03, 0.04};
void main(){
// to avoid copying
for (auto &i: ints){
std::cout<< i <<std::endl;
}
// to prevent to change the value
for (auto const i: ints){
std::cout<< i <<std::endl;
}
// both of them
for (auto const &i: ints){
std::cout<< i <<std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment