When writing some functions, I found a const keyword in parameters like this:
void MyClass::myFunction(const MyObject& obj,const string& s1,const string& s2,const string& s3){
}
often causes splitting a line into 2 lines in IDE or vim, so I want to remove all const keywords in parameters:
void MyClass::myFunction(MyObject& obj,string& s1,string& s2,string& s3){
}
is that a valid reason to not using const? Is it maintainable to keep the parameter objects unchanged manually?
constyou have a strong hint that you don't need to bother how it might be changed in the function. – tofro Sep 22 '16 at 09:05typedef-ing shorthands for commonly used types, just to save a few keystrokes here and there to keep within the line length limit. Don't do this. Format your code for the logic, not for the format of your monitor. – cmaster - reinstate monica Sep 22 '16 at 21:05stringinstead ofconst string, but usingstring &instead ofconst string &changes the semantics - it doesn't just affect readability. (I suspect it prevents you from passing a temporarystringas an argument) – user253751 Sep 22 '16 at 21:51in IDE or vimAre you implying Vim is not an ide? runs – Sebi Sep 23 '16 at 06:28constto tell you. – user253751 Sep 24 '16 at 11:28