function prototypes

Do not use any math libraries to calculate the area and circumference

I am writing a program to calculate area or circumference using no classes.
I have my code written out but am missing some key areas and am completely lost. I get error C2661: no overloaded function takes 0 arguments.
Last edited on
1
2
3
std::cin >> GetArea() << endl;
//...
std::cin >> GetArea() << endl;


These lines make no sense.

Did you mean to use cout instead of cin?

Also, you must give GetArea and GetCircumference a radius.
I have added that but am now getting undeclared identifier for circumference and area. Also I am still getting
error C2661: 'GetArea' : no overloaded function takes 0 arguments

Last edited on
To simplify your program, why not just output immediately for a given radius both the circumference and the area.
See my comments:

1
2
3
4
5
6
7
8
9
double GetArea(double radius)
{
// before you use the variable "area", you must declare it:
double area;  // <- this declares it.

std::cout << "Area using value semantics: ";
area = (radius * radius) * PI;   // you correctly calculate the area here
std::cin >> area;  // then here, you discard that area and replace it with input from the user
}


GetArea/GetCircumference should not be using cin. cin is for getting input from the user. You're not doing that here.

Instead, these functions should be giving the area back to the code that's calling them. You do this by returning that value: return area;


As for your 0 arguments error... when you call GetArea, you need to give it a radius to use. In your above code you're not giving it anything, so how can it know what area to get?

1
2
3
GetArea(5);  // this gets the area of a circle whose radius = 5
GetArea(10);  // this gets the area where radius=10
GetArea();  // ??  what area do you hope to get here ?? 
I have everything running correctly except one last thing.

void GetArea(double radius, double& area)
{
std::cout << "Area using reference semantics: ";
}

I must use reference semantics. That is, you pass in the radius and a reference to an existing variable. So what exactly is the variable I am referencing? Am I declaring a new variable in the void function?
Topic archived. No new replies allowed.