Hey.
Got a really stupid problem. I get the errors below from the first call below to set_from_slider_value. I tried casting the arguments to the parameters the function takes, but no cigar. I then created x and sv2, and passed 0 and 100 as min and max, and that worked...Code:void Board::Set_Computer_Delay(const Slider_Value& sv) { set_from_slider_value(sv, computer_delay, min_computer_delay, max_computer_delay); int x = 0; Slider_Value sv2(23, 34); set_from_slider_value(sv2, x, 0, 100); }computer_delay, min_computer_delay and max_computer delay are declared as:1>c:\documents and settings\bill\my documents\visual studio 2005\projects\checkers\checkers_sdl\checkers_sdl\board.cpp(1272) : error C2665: 'set_from_slider_value' : none of the 2 overloads could convert all the argument types
1> c:\documents and settings\bill\my documents\visual studio 2005\projects\checkers\checkers_sdl\checkers_sdl\slider_value.h(22): could be 'int &set_from_slider_value(const Slider_Value &,int &,int,int)'
1> while trying to match the argument list '(const Slider_Value, unsigned short, unsigned short, unsigned short)'The set_from_slider_value functions:Code:unsigned short min_computer_delay; // Minimum computer delay in milliseconds. unsigned short max_computer_delay; // Maximum computer delay in milliseconds. unsigned short computer_delay; // Seconds it takes for the computer to make a move.Cheers.Code:int& set_from_slider_value(const Slider_Value& sv, int& value, int min, int max); // Exactly the same as above except doesn't clamp. int& set_from_slider_value(const Slider_Value& sv, int& value, int max); int& set_from_slider_value(const Slider_Value& sv, int& value, int min, int max) { if(sv.denominator == 0) { throw LRE_Exception("Tried to divide by zero in " + std::string(__FUNCTION__) + '.'); } value = std::max(min, std::min(sv.numerator * max / sv.denominator, max)); return value; } int& set_from_slider_value(const Slider_Value& sv, int& value, int max) { if(sv.denominator == 0) { throw LRE_Exception("Tried to divide by zero in " + std::string(__FUNCTION__) + '.'); } value = sv.numerator * max / sv.denominator; return value; }


Reply With Quote


Bookmarks