[Solved] bug in the code below in terms of synthax, design? [closed]


In the current form all the methods are private. You can make getAverage() and addElement() public by:

class Elements
{
    int nbValues;
    int values[MAX];
    double coefs[MAX];

    Element(){}

    public: // all the members & methods below will be public

    double getAverage()
    {
    int sum;
    for(int i =1; i<= MAX; i++)
    {
        sum = sum+values[i]*coefs[i];
    }
    return sum/nbValues;
    }
    void addElement(int value, double coef)
    {
        values[nbValues]=value;
    coefs[nbValues]=coef;
    ++nbValues; 
    }
}

solved bug in the code below in terms of synthax, design? [closed]