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
Post a Comment