On May 21, 8:58*pm, Philipp Kraus <philipp.kr...@flashpixx.de> wrote:
> Hello,
>
> I' writing a class with a method, that should get a parameter for
> comparision like <, <=, > or >=. The method must compare some float
> values but the user of the method should be set the comparision. My
> first idea is to use an enum with 4 states of comparision, but is there
> a better solution?
>
> In pseudocode:
>
> myclass::mymethod( comparision_operator p_comp ) {
> * * float a,b;
> * * if ( p_comp(a,b))
> * * * *do something
>
> }
Usually function objects are used there in C++. Objects of class that
overloads 'bool operator()(float,float) const'.
|