What above said ^
From the code I'm assuming ball is a class? If so, make speed a private variable, and set its initial value (5 in your example) in your constructor for the class.
Next, if move() is being called by a function inside the class, then you should be able to modify speed in that function, right before you call move().
void ball::MyFunction()
{
//...
//some code
//...
speed++;
this.move();
}
If move() is being called by an object, say inside main(), then you need to create methods in your function to adjust the speed.
main()
{
ball MyBall;
//...
//some code
//...
MyBall.AddSpeed();
MyBall.move();
//etc
}
void ball::AddSpeed()
{
speed++;
}
The second example does not require modification to your move() and its a bit more professional. Just remove the declaration of speed from the function, and make it a class variable. Similarly if needed, you can have a LowerSpeed() method. Hope this helps