I'm attempting to make a print function where I combine a few pieces of text and a numerical value obtained from a function. I receive the error when compiling:
Error Message
error: invalid operands of types ‘const char [5]’ and ‘double (*)(double, double, double, double, double)’ to binary ‘operator+’
wrtResult = ("s = " + sortValues + " kJ/(kg.K)");
Source Code
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
void eqOut(double sortValues(double tempC,double xo,double yo,double xone,double yone))
{
string wrtResult;
wrtResult = ("s = " + sortValues + " kJ/(kg.K)"); // This is the line in question
cout << wrtResult;
}
int main()
{
double tempC;
double xo, xone, yo, yone;
cout << "Enter a temp in C : ";
cin >> tempC;
if ((tempC < 150) || (tempC > 500))
{
cout << "Enter a value between 150 and 500 next time!" << endl;
}
else
{
double sortValues(double tempC,double xo,double yo,double xone,double yone);
{
double temp150 = 150, temp200 = 200,
temp250 = 250, temp300 = 300,
temp400 = 400, temp500 = 500;
double ent150 = 7.2810, ent200 = 7.5081,
ent250= 7.7100, ent300 = 7.8941,
ent400 = 8.2236, ent500 = 8.5153;
double x;
if (tempC == 150)
{
cout << "7.2810 kJ/(kg.K)";
}
if (tempC > 150 && tempC < 200)
{
x = tempC;
xo = ent150;
xone = ent200;
yo = temp150;
yone = temp200;
return (yone+(yone-yo)*((x-xo)/(xone-xo)));
}
if (tempC > 200 && tempC < 250)
{
x = tempC;
xo = ent200;
xone = ent250;
yo = temp200;
yone = temp250;
return (yone+(yone-yo)*((x-xo)/(xone-xo)));
}
if ((tempC > 250) && (tempC < 300))
{
x = tempC;
xo = ent250;
xone = ent300;
yo = temp250;
yone = temp300;
return (yone+(yone-yo)*((x-xo)/(xone-xo)));
}
if ((tempC > 300) && (tempC < 400))
{
x = tempC;
xo = ent300;
xone = ent400;
yo = temp300;
yone = temp400;
return (yone+(yone-yo)*((x-xo)/(xone-xo)));
}
if ((tempC > 400) && (tempC < 500))
{
x = tempC;
xo = ent400;
xone = ent500;
yo = temp400;
yone = temp500;
return (yone+(yone-yo)*((x-xo)/(xone-xo)));
}
}
}
eqOut;
return 0;
}