Reputation: 403
void displayCost();
double computeArea();
double roundCost();
int main()
{
return 0;
}
void displayCost(string name, int size)
{
double area = computeArea(size);
cout << "Since a " << size << "-inch pizza covers" << area << "square inches, "
<< name << ", then a 12 cents per square inch, the cost will be" << 12*area
<< " - which rounds to" << roundCost();
}
double computeArea(int size)
{
double radius = size/2;
double area = pi*radius*radius;
return area;
}
double roundCost(double price)
{
double roundedCost = ceil(price*100)/100;
return roundedCost;
}
It happens on the line at double area = computeArea(size);
. I don't understand why it says I'm not passing an argument in when I clearly am.
Upvotes: 0
Views: 1490
Reputation: 1
You've declared computeArea to take exactly zero arguments in the prototype (above main). The fact that you've then defined it to take a double down below is beside the point. Inside main, you're calling it with an argument, which, according to the prototype, is wrong.
Upvotes: 0
Reputation: 119069
C++ differs from C in that a forward declaration of a function must specify the number and types of arguments. Whereas in C
double computeArea();
means that there is some function called computeArea
that returns double
, in C++ it is the same as
double computeArea(void);
That is, it specifies that computeArea
takes no arguments.
Presumably the difference is because C++ allows functions to be overloaded, whereas C doesn't.
Upvotes: 0
Reputation: 881183
double computeArea();
double area = computeArea(size);
double computeArea(int size) {
One of these things is not like the others, ...
You need to fix your prototype (the first one) to match the actual function:
double computeArea(int);
And, of course, ditto for the other prototypes as well.
Upvotes: 5
Reputation: 8805
You are messing up your forward declarations, they also have to reflect the type of parameters of your function.
void displayCost(string, int);
double computeArea(int);
double roundCost(double);
Upvotes: 0