Hi,
Usually when I am writing some code, I do not use const (I have now realized that may be I should. So one of my functions could look like this:
Then I just put a const modifier before float NewSpeed:Code:void setSpeed(float NewSpeed) {Speed=NewSpeed;}
I understand that it tells the compiler that NewSpeed will never be changed during the execution of the function. But would it make the function faster? Or: will NewSpeed occupy less memory?Code:void setSpeed(const float NewSpeed) {Speed=NewSpeed;}
And:
Code://will this float getSpeed() const {return Speed;} //be faster than this: float getSpeed() {return Speed;}
What about the 'mutable' modifier? Will it make a function faster? I have really never seen mutable being used in regular code. Why is that?
thnx in advance![]()



LinkBack URL
About LinkBacks
. So one of my functions could look like this:



CornedBee