问题
i am having an issue with this code so all the tarif = x; is underlined when i run the program, but i don't see how i could solve this and exactly what is the error ? thank you for your help !
double saaq::Camion::tarificationAnnuelle() const
{
double tarif;
if(m_nbEssieux == 2 && m_poids >= 3001 && m_poids <= 4000)
{
tarif = 570,28;
}
if(m_nbEssieux == 2 && m_poids >= 4001)
{
tarif = 905,28;
}
if(m_nbEssieux == 4)
{
tarif = 2206,19;
}
if(m_nbEssieux == 5)
{
tarif = 2821,76;
}
if(m_nbEssieux >= 6)
{
tarif = 3729,76;
}
return tarif;
}
回答1:
It's an obvious typo when you write double constant:
tarif = 570,28;
should be
tarif = 570.28;
that applies to all other double assignments..
Also you should initialise your tarif
variable,
double tarif = 0;
来源:https://stackoverflow.com/questions/59004704/how-do-i-get-rid-of-this-error-right-operand-of-comma-operator-has-no-effect-w