“cannot be used as a function error”

后端 未结 6 1158
孤城傲影
孤城傲影 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 02:03

    Modify your estimated population function to take a growth argument of type float. Then you can call the growthRate function with your birthRate and deathRate and use the return value as the input for grown into estimatedPopulation.

    float growthRate (float birthRate, float deathRate)     
    {    
        return ((birthRate) - (deathRate));    
    }
    
    int estimatedPopulation (int currentPopulation, float growth)
    {
        return ((currentPopulation) + (currentPopulation) * (growth / 100);
    }
    
    // main.cpp
    int currentPopulation = 100;
    int births = 50;
    int deaths = 25;
    int population = estimatedPopulation(currentPopulation, growthRate(births, deaths));
    

提交回复
热议问题