C++ – “Expression must be modifiable lvalue”

c++operatorsvisual-studio

The following code gives this error and I for the life of me can not understand why. Any help would me much appreciated.

jdn_t julian_to_jdn(year_t year, month_t month, day_t day)
{
    double a = (14 - month) / 12;
    year = year + 4800 - a;
    month = month + (12 * a) - 3;
    return day + (153 * month + 2) / 5 + 365 * year + year / 4 = 32083.5;
}

Error 8 error C2106: '=' : left operand must be l-value C:\Users\Italo\Documents\F14 CPA Fanshawe\C++\Project1Files\8. Calendar (D)\Calendar\julian.cpp 46 1 Calendar

Best Solution

You are trying to assign a value to an expression - which itself gives a value

return day + (153 * month + 2) / 5 + 365 * year + year / 4 = 32083.5;

remove " = 32083.5" part to give

return day + (153 * month + 2) / 5 + 365 * year + year / 4;
Related Question