Code:
void Test()
{
float dt = 0.3;
float playTime = 1;
while ( playTime > 0.0 )
{
const float delta = std::min( playTime, dt );
std::cout << delta << std::endl;
playTime -= delta;
}
}
Result:
0.3
0.3
0.3
0.1
In c++, const keyword means doesn't change. So, we use the keyword const to make vars constant.
But in this case,
Why const var, delta can be changed every time being called?
Since, while loop start new code block(in stack area),
So, I think variable, delta exist already for while looping execution.