Error: cannot convert 'double(*)(double,double)' to 'double'

Hi, I'm writing this program and it says "Error: cannot convert 'double(*)(double,double)' to 'double' for argument '3' to 'double futureSal (int, double, double)'". Can anyone give me some advice?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <cmath>
using namespace std;

double hikerate (double thisSal, double lastSal);
double futureSal (int year, double thisSal, double hikerate);

int main()
{
    double thisSal, lastSal;
    int year;
    char ans;
    do
    {
    cout << "Input the annual salary of this year and last year." << endl;
    cin >> thisSal >> lastSal;
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    cout << "The rate of raise is " << hikerate (thisSal,lastSal) << "%" << endl;
    cout << "Input the number of years wanna forecast." << endl;
    cin >> year;
    cout << "The salary of " << year << " year(s) later is " << futureSal (year, thisSal, hikerate)<< endl;
    cout << "Wanna gauge again? ";
    cin >> ans;
        }
    while (ans=='y'||ans=='Y');
    return 0;
}

double hikerate(double thisSal, double lastSal)
{
    return ((thisSal-lastSal)*100/lastSal);
}
double futureSal (int year, double thisSal, double hikerate)
{
    double rate;
    rate = (1+hikerate/100);
    return (thisSal*(pow(rate,year)));
}


The function hikerate is the rate of salary increment, which has 2 argument thisSal and lastSal. hikerate itself is also an argument of function futureSal.
Last edited on
1
2
// cout << "The salary of " << year << " year(s) later is " << futureSal (year, thisSal, hikerate)<< endl;
   cout << "The salary of " << year << " year(s) later is " << futureSal (year, thisSal, hikerate(thisSal,lastSal) ) << endl;
Thanks, I got it.
Topic archived. No new replies allowed.