Mooophy / Cpp-Primer

C++ Primer 5 answers
Creative Commons Zero v1.0 Universal
8.06k stars 3k forks source link

[Ex 6.18] Add const and reference to function declarations #837

Closed iamvickynguyen closed 11 months ago

iamvickynguyen commented 11 months ago

Exercise 6.18

a) The compare function takes 2 parameters, each of which should be a reference to const matrix because the function doesn't modify the objects. Also, we can't pass const matrix objects to the compare function if it doesn't accept const objects

b) The change_val function is ok, but I think it's better if we make it accept a reference to vector\::iterator instead (better performance). Also add parameter names to make the function clearer