Is it all right to call a function that returns a value without storing the value returned in a variable?
Here is some sample code:
class Test
{
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
boolean validity()
{
//some code
isLeap();
}
boolean isLeap(int y)
{
if(y%400==0 || (y%100!=0 && y%4==0))
{
days[1] = 29;
return true;
}
else
{
days[1] = 28;
return false;
}
}
}
Yes, it is allowed. The compiler won’t throw an error. But in your case it does not make any sense to use up processor time for something unnecessary.