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.
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
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 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?