“不能用作函数误差” [英] "cannot be used as a function error"
问题描述
我在写一个简单的程序,使用在不同的.cpp文件中找到的函数。我的所有原型都包含在头文件中。我将一些函数传递到其他函数,不知道我是否正确地做。我得到的错误是'functionname'不能用作函数。它不能使用的函数是 growthRate
函数和 estimatedPopulation
函数。数据通过输入函数(我认为是工作)输入。
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 functions and am not sure if I am doing it correctly. The error I get is "'functionname' cannot be used as a function". The function it says cannot be used is the growthRate
function and the estimatedPopulation
function. The data comes in through an input function (which I do think is working).
谢谢!
strong>头文件:
header file:
#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
growthRate函数: / p>
growthRate function:
#include "header.h"
float growthRate (float birthRate, float deathRate, float growthrt)
{
growthrt = ((birthRate) - (deathRate))
return growthrt;
}
estimatedPopulation函数:
$ b
estimatedPopulation function:
#include "header.h"
int estimatedPopulation (int currentPopulation, float growthrt)
{
return ((currentPopulation) + (currentPopulation) * (growthrt / 100);
}
main:
main:
#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;
}
推荐答案
变量名和函数名。
重命名局部变量
这篇关于“不能用作函数误差”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!