c++ - One Method to be seen throughout the entire Project -


i have question. have randomnumber function want available classes.

in main,

i have function

int randomrange(int min, int max) {     int newvalue = (rand() % max) + min;      if ( newvalue > max )         newvalue = max;     if ( newvalue < min )          newvalue = min;      return newvalue; } 

but want classes able use function. how go that?

create header:

#ifndef random_range_h_inlcuded_ #define random_range_h_inlcuded_  int randomrange(int, int);  #endif 

then include header in file needs use function.

when have time, might want write better implementation of function.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -