“cannot be used as a function error”

后端 未结 6 1168
孤城傲影
孤城傲影 2021-02-19 01:45

I am writing a simple program that uses functions found in different .cpp files. All of my prototypes are contained in a header file. I pass some of the functions into other fun

6条回答
  •  醉酒成梦
    2021-02-19 01:48

    You can't pass a function as a parameter. Simply remove it from estimatedPopulation() and replace it with 'float growthRate'. use this in your calculation instead of calling the function:

    int estimatedPopulation (int currentPopulation, float growthRate)
    {
        return (currentPopulation + currentPopulation * growthRate / 100);
    }
    

    and call it as:

    int foo = estimatedPopulation (currentPopulation, growthRate (birthRate, deathRate));
    

提交回复
热议问题