Many times I write C++ functions I seem to use many more const
modifiers than other folks.
For example, I write Excel .xlsx files and I use LibXL library for this, and the documentation mentions a function like this:
bool writeNum(int row, int col, double value, Format* format = 0)
I happened to inherit this function and my signature looks like this:
bool XLAPIENTRY writeNum(const int row, const int col, const double value, IFormatT<wchar_t> * format = 0);
Note the const int
s for the row and the column.
Question: is it safe to leave out const
for int
s? (It's obviuos that for pointers, leaving out const for pointers is dangerous, but doing something a local copy of an int
is not that dangerous). Note that the original header containing writeNum function doesn't mention const-ing the int
s, too. Why is here the const
modifiers left out?