Can't run random generator in classes?

Hello I was trying to make a simple text based game by using classes and the rand function. I was trying trying to make an attack function for a character to randomly take off a number of damage between two different numbers, exmaple: 30-70 damage.However,once I compiled the program I got an error on the file because it won't let me set up the rand function in the class neither would it let me set it up as a global scope. So my question is, is there a way to set up the random function in a class? If not, how can you make a character attack in a certain number range without using the random function?
Well, you could just set pre-determined values, like:
health= health - 20
but I would prefer to use the random number generator (Makes it realistic).
If not, how can you make a character attack in a certain number range without using the random function?

You could just use a function or, like I said above, set values. Personally, instead of using classes I would try using functions.
Last edited on
Topic archived. No new replies allowed.