Hey, I keep getting this error, but from its description, I can't really tell how to fix it besides from what I've already tried, so any explanation would be great. The error I get is: clientrectlib.cpp(32) : error C2664: 'calcMinMaxValue' :cannot convert parameter 1 from 'overloaded-function' to 'float &'.
The code is the following: (This is clientrectlib.cpp)
#include <iostream>
#include "Rect.h"
using namespace std;
int main() {
cout << "Client to test the Rect library\n";
cout << "Creating some variable of type Rect ...." << endl;
RectStruct *rect01 = new RectStruct;
RectStruct *rect02 = new RectStruct;
RectStruct rect03;
cout << "Assigning values to them ...." << endl;
assignRectValues(rect01,10.51,20,40.77,50);
assignRectValues(rect02,20.83,30,80.99,10);
assignRectValues(&rect03,10.7,8.9,10,100);
cout << "Printing out their fields .. " << endl;
printRectValues(rect01);
printRectValues(rect02);
printRectValues(&rect03);
cout << "Printing out their areas .. " << endl;
cout << "Area of rect01: " << calcRectArea(rect01) << endl;
cout << "Area of rect02: " << calcRectArea(rect02) << endl;
cout << "Area of rect03: " << calcRectArea(&rect03) << endl;
cout << "Comparing the area of rect01 and rect03... " << endl;
cout << "The area of rect01 is " << calcRectArea(rect01) << endl;
cout << "and area of rect03 is " << calcRectArea(&rect03) << endl;
calcMinMaxValue(min, max);
return 0;
}
and (This is Rect.cpp)
#include "Rect.h"
void assignRectValues(RectStruct *r, float xcoord, float ycoord, float widthValue, float heightValue) {
r->x = xcoord;
r->y = ycoord;
r->width = widthValue;
r->height = heightValue;
return;
}
void printRectValues(const RectStruct *r) {
cout << "(x,y) = (" << r->x << ", " << r->y << ")" << endl;
cout << "(width,height) = (" << r->width << ", " << r->height << ")" << endl;
return;
}
float calcRectArea(const RectStruct *r){
return r->height * r->width;
}
void calcMinMaxValue(float &min, float &max){
RectStruct *rect01 = new RectStruct;
RectStruct rect03;
if(calcRectArea(rect01) < calcRectArea(&rect03)){
min = calcRectArea(rect01);
max = calcRectArea(&rect03);
}
else{
min = calcRectArea(&rect03);
max = calcRectArea(rect01);
}
cout << "The minimum value is " << min << endl;
cout << "and the maximum value is " << max << endl;
return;
}