As stated in book Effective C++: "Use const whenever possible.", one would assume that this definition: Vec3f operator+(Vec3f &other); would be better defined as Vec3f operator+(const Vec3f &other) const; or even better as const Vec3f operator+(const Vec3f &other) const;.
Or an example with 5 const keywords: const int*const Foo(const int*const&)const;
Of course, you should only include const where there can be one. What Im asking is it a good practice to use them whenever possible? While it does give you more error safe code, it can get quite messy. Or should you, for example, ignore pointer and reference const (unless you really need it), and use it only on the types itself, as in const int* Foo(const int* parameter)const;, so it doesnt end up too messy?
Additional info: http://duramecho.com/ComputerInformation/WhyHowCppConst.html
Thanks in advance!
constis far more important than valueconstwhen passed as function argument. When passing by value, you are passing a copy, unlike when you pass by pointer or reference.conston parameters passed by value is ignored completely, so it's not just less important, it's unimportantvoid foo(int const a) { a += 1; }... If you are not usingconston value parameter and change it by mistake, you are changing copy. Unlike with reference or pointer. So it's not that big of a deal not to use it in function declaration. But if you use it, it is not ignored, it is enforced by compiler even for copy.