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

jQuery clickable div with working mailto link inside -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -