The problem is how you are putting the parentheses in the if
:
if ((_base||_altura) <= 0){
As it is right now, you are first processing (_base||_altura)
and the result you are comparing it with <= 0
. So the problem is that if either of the two numbers is different from zero, the OR will return 1 which is a value greater than or equal to zero and will enter the if
.
The solution would be to compare each of the values with zero individually:
if (_base <= 0 || _altura <= 0){
throw string {"ERROR: la base y la altura tienen que ser mayor que 0 "};
}
else {
base = _base;
altura = _altura;
}