Hello, I made a program that worked perfectly on one of my pcs. When I moved it to another computer I am getting an error now stating that I need to include a pointer on my fmin and fmax functions. I'ts somewhat lengthy but I want to know if maybe te requirement for the pointer might be because of something else in my code. If you can explain why I need to use pointers only for fmin and fmax if its necessary that would be great.
calc.h
#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();
bool cont(char choice);
void difference();
float fmax(float valArr[],int Size);
float fmin(float valArr[],int Size);
};
calc.cpp
#include "calc.h"
#include <cfloat>
#include <iostream>
#include <climits>
#include <cmath>
calc::calc()
{
std::cout<<"Please Input Your Values"<<std::endl;
std::cout<<"Up To 100 Values"<<std::endl;
std::cout<<"Type 0 When Ready To Calculate"<<std::endl;
}
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,x);
fmin(valArr,x);
}
avg = sum/x;
for ( int i=0; i<x; i++)
{
var += (valArr[i] - avg) * (valArr[i] - avg);
}
var /= x-1;
float stdev = sqrt(var);
}
float calc::fmax(float valArr[],int Size)//here is where the error occurs
{
mAx = valArr[0];
for (int x=1; x<Size;x++)
{
if (valArr[x]>mAx)
mAx=valArr[x];
}
return mAx;
}
float calc::fmin(float valArr[],int Size) //here is where the error occurs
{
mIn = valArr[0];
for (int x=1; x<Size;x++)
{
if (valArr[x]<mIn)
mIn=valArr[x];
}
return mIn;
}
void calc::outputs()
{
std::cout<<"Sum of the values are: "<<sum<<std::endl;
std::cout<<"The Difference of the Values are: "<<sub<<std::endl;
std::cout<<"Mult equals: "<<mult<<std::endl;
std::cout<<"Minimum Value: "<<fmin<<std::endl;
std::cout<<"Maxmimum Value: "<<fmax<<std::endl;
std::cout<<"The Average is: "<<avg<<std::endl;
std::cout<<"Variance (pop) is: "<<var<<std::endl;
std::cout<<"Standard Deviation(pop) is: "<<stdev<<std::endl;
std::cout<<std::endl;
std::cout<<"Do You Need To Enter In A New Set Of Values? (Y/N): "<<std::endl;
}
bool calc::cont(char choice)
{
std::cin>>choice;
if (choice=='y'||choice=='Y')
{
return true;
}
else
{
return false;
}
}
void calc::difference()
{
if (x==0)
{
sub=valArr[0];
}
else
{
sub-=valArr[x];
}
}
main.cpp
#include "calc.h"
#include <cfloat>
#include <iostream>
#include <climits>
#include <cmath>
#include <cstdio>
int main()
{
calc start;
do
{
start.calculations();
start.outputs();
}while(start.cont(true));
}
error:
calc::fmin': function call missing argument list; use '&calc::fmin' to create a pointer to member
and when I try that this pops up:
'float &calc::fmax(float [],int)' : overloaded function differs only by return type from 'float calc::fmax(float [],int)'
1>calc.h(22) : see declaration of 'calc::fmax'
calc.cpp(39): error C2040: 'calc::fmax' : 'float &(float [],int)' differs in levels of indirection from 'float (float [],int)'
Again thank you for taking time to read.