Я пишу простую программу, которая использует функции из разных файлов .cpp. Все мои прототипы содержатся в заголовочном файле. Я передаю некоторые функции в другие функции и не уверен, что делаю это правильно. Я получаю ошибку: "имя функции не может быть использовано как функция" . Эта функция, которую она не может использовать, является функцией growthRate
и функцией estimatedPopulation
. Данные поступают через функцию ввода (которая, я думаю, работает).
Спасибо!
заголовочный файл:
#ifndef header_h
#define header_h
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
//prototypes
void extern input(int&, float&, float&, int&);
float extern growthRate (float, float);
int extern estimatedPopulation (int, float);
void extern output (int);
void extern myLabel(const char *, const char *);
#endif
Функция GrowRate:
#include "header.h"
float growthRate (float birthRate, float deathRate, float growthrt)
{
growthrt = ((birthRate) - (deathRate))
return growthrt;
}
Расчетная функция населения:
#include "header.h"
int estimatedPopulation (int currentPopulation, float growthrt)
{
return ((currentPopulation) + (currentPopulation) * (growthrt / 100);
}
Основной:
#include "header.h"
int main ()
{
float birthRate, deathRate, growthRate;
char response;
int currentPopulation, years, estimatedPopulation;
do //main loop
{
input (currentPopulation, birthRate, deathRate, years);
growthRate (birthRate, deathRate, growthrt);
estimatedPopulation (currentPopulation, growthrt);
output (estimatedPopulation (currentPopulation, growthrt));
cout << "\n Would you like another population estimation? (y,n) ";
cin >> response;
}
while (response == 'Y' || response == 'y');
myLabel ("5-19", "12/09/2010");
system ("Pause");
return 0;
}