I have a legacy function that looks like this:
int Random() const { return var_ ? 4 : 0; } and I need to call a function within that legacy code so that it now looks like this:
int Random() const { return var_ ? newCall(4) : 0; } The problem is that I'm getting this error:
In member function 'virtual int Random() const': class.cc:145: error: passing 'const int' as 'this' argument of 'int newCall(int)' discards qualifiers Now I know in order to fix this error I can make my newCall() a const function. But then I have several funciton calls in newCall() that I have to make, so now I would have to make all of those function calls const. And so on and so forth until eventually I feel like half my program is going to be const.
My question: is there any way to call a function within Random() that isn't const? Or does anyone have any ideas on how to implement newCall() within Random() without making half my program const.
Thanks
-josh
this? why?const, but whether those functions are actuallyconst: do they modify any member of the object? If not, then mark them as const.