c++ - If you include const in a function, is & redundant? -


will 2 function specifications below compile same thing? can't see copy needed if you're using const. if aren't same, why?

void(const int y); void(const int& y); 

not same. if argument changes after it's passed (e.g. because it's changed thread), first version unaffected because has copy. in second variant, function called may not change argument itself, affected changes y. threads, might mean requires mutex lock.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -