How do i get rid of this error right operand of comma operator has no effect ( wunsued value)? [closed]

笑着哭i 提交于 2020-01-06 05:40:31

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!