takie coś mam zrobić: operator / ( [a;b]/[c;d] = [min(a/c,a/d,b/c,b/d); max(a/c,a/d,b/c,b/d)] )
przeciążyć operator, no i sobie napisałem, dla mnożenia zrobiłem identyczny i działa poprawnie, ale mnożenie zawsze mi zwraca 0
class interval{
double left, right;
...
interval operator / (const interval& object, const interval& object2)
{
if(object2.left || object2.right == 0) return 0;
double min,max;
max = min = object.left / object2.left;
double temp;
temp = object.left / object2.right;
if(temp < min) min = temp;
if(temp > max) max = temp;
temp = object.right / object2.left;
if(temp < min) min = temp;
if(temp > max) max = temp;
temp = object.right / object2.right;
if(temp < min) min = temp;
if(temp > max) max = temp;
return interval(min,max);
}
funkcja main:
interval object(1,5);
interval object2(120,4);
interval object3 = object / object2;