Let's say I have C ++ - a function that looks like this:
double myfunction(double a, double b) {
}
What I then call this:
double a = 1.0;
double b = 2.0;
double good_r = myfunction(a, b);
double bad_r = myfunction(b, a);
I would like to make sure that aand bnever appear in the wrong order. What is the best way to provide this in C ++?
Other languages allow named parameters, for example:
double good_r = myfunction(a=a, b=b);
double bad_r = myfunction(a=b, b=a);
double bad_r = myfunction(b=b, a=a);
Or maybe the problem can be partially solved using types, i.e.
double my_type_safe_function(a_type a, b_type b) {
}
a_type a = 1.0;
b_type b = 2.0;
double good_r = myfunction(a, b);
double bad_r = myfunction(b, a);
EDIT: , " ". , a b . , height width. , . , (.. ). , "" . , , (width, height), , , (height, width). , . , 6 .
, , , (.. - ).