Hello, I am trying to start implementing functions from a class into my Calculator just to get used to the idea of it. when I tried calling for my min max functions into my calculations function it is spitting out an error arguement of type "float" is not compatable with parameter of type "float". I have tried everything I could think of which is probably not much since i've only been doing programming for maybe 2-3 weeks XD. But want to thank you all in advance for the help.

header file

#pragma once
class calc
{
private:
    int Size;
    float sum;
    int x;
    float Max;
    float Min;
    float mult;
    float var;
    float stdev;
    float sub;
    float valArr[100];
    float avg;

public:
    calc();
    void calculations();
    void outputs();
    void inputs();
    bool cont();
    float difference();
    void maxValue(float valArr[],int Size);
    void minValue(float valArr[],int Size);
};

calc.cpp (portion that im having the issue)

void calc::calculations()
{
    for (x=0;x<Size;x++)
    {
    std::cin>>valArr[x];
    maxValue(valArr[x],Size);//error here
    minValue(valArr[x],Size);//error here
    sum+=valArr[x];
    difference();
    mult*=valArr[x];

    }
    avg = sum/x;
       for (int x=0; x<Size; x++)
    {
        var += (valArr[x] - avg) * (valArr[x] - avg);
    }
    var /= x-1;
    float standDev = sqrt(var);
}




void calc::maxValue(float valArr[],int Size)
{
    float Max = valArr[0];
    for (int x=1; x<Size;x++)
    {
        if (valArr[x]>Max)
            Max=valArr[x];
    }

}

void calc::minValue(float valArr[],int Size)
{
    float Min = valArr[0];
    for (int x=1; x<Size;x++)
    {
        if (valArr[x]<Min)
            Min=valArr[x];
    }

}

probably should have not started with arrays also to start learning to implement functions and call functions with parameters XD.

i changed all the functions involving min and max to fmin() and fmax() and still getting that valArr[x] error
the revised cpp for the header(fmin is formatted the same way)

float calc::fmax(float valArr[],int Size)
{
    float Max = valArr[0];
    for (int x=1; x<Size;x++)
    {
        if (valArr[x]>Max)
            Max=valArr[x];
    }

}



void calc::calculations()
{
    for (x=0;x<Size;x++)
    {
    std::cin>>valArr[x];
    fmax(valArr[x],Size);
    fmin(valArr[x],Size);
    sum+=valArr[x];
    difference();
    mult*=valArr[x];

    }

maxValue(valArr[x],Size);//error here

You are passing a discrete value (an element of the array) to the function that is expecting the array iteself.

Try
maxValue(valArr, Size);

ok so the good news I got almost all of my functions working now that the darn thing will actually run. And thank you for the explanation of valArr. I'm still not able to properly calculate min it keeps spitting out -1.07E8 I tried removing the min = valArr[0] from my min function because I was thinking it would reset min to that every time the function is called for in the for loop. No luck =( I had a min issue like this before but I just used min=FLT_MAX to get around that but it wont let me use that now that I am trying to calculate min in a function.

void calc::calculations()
{
    for (x=0;x<Size;x++)
    {
    std::cin>>valArr[x];
        if(valArr[x]==0)
        {
            break;
        }
    sum+=valArr[x];
    difference();
    mult*=valArr[x];
    fmax(valArr,Size);
    fmin(valArr,Size);
    }
    avg = sum/x;
       for ( int i=0; i<x; i++)
    {
        var += (valArr[i] - avg) * (valArr[i] - avg);
    }
    var /= x-1;
    float standDev = sqrt(var);
}


float calc::fmin(float valArr[],int Size)
{
     mIn = valArr[0];
    for (int x=1; x<Size;x++)
    {
        if (valArr[x]<mIn)
            mIn=valArr[x];
    }
    return mIn;
}

nm i figured it out needed to cast valArr,x into the function to get max and min.

This question has already been answered. Start a new discussion instead.