Errors again

Hello everyone I post last night with this same code, and I got a lot of advice. But there are 3 more errors that persist after I changed the code a bit. Anyone know whats wrong?



Here are the errors:




1>------ Build started: Project: circle, Configuration: Debug Win32 ------
1>Compiling...
1>circle.cpp
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(39) : error C2664: 'diameter' : cannot convert parameter 1 from 'double (__cdecl *)(double,double,double,double)' to 'double'
1> Context does not allow for disambiguation of overloaded function
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(40) : error C2664: 'circumference' : cannot convert parameter 1 from 'double (__cdecl *)(double,double,double,double)' to 'double'
1> Context does not allow for disambiguation of overloaded function
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(41) : error C2664: 'area' : cannot convert parameter 1 from 'double (__cdecl *)(double,double,double,double)' to 'double'
1> Context does not allow for disambiguation of overloaded function
1>Build log was saved at "file://c:\Users\Emcy\Documents\Visual Studio 2008\Projects\circle\circle\Debug\BuildLog.htm"
1>circle - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========





And here is the code:





#include <iostream>
#include <cmath>

using namespace std;

double radius(double x, double y, double xs, double ys);
double diameter(double x);
double circumference(double x);
double area(double x);

const double pi = 3.141;

int main()

{
double centerX;
double centerY;
double pointX;
double pointY;
double radiusMain;
double diameterMain;
double circumferenceMain;
double areaMain;

cout << "This program will calculate the radius, diameter, circumference and area \n of a circle if the user gives the locaction of the center point and \n a point on the circle."<< endl;
system("pause");
system("cls");

cout << "Enter the x coordinate for the center of the circle. \n" << endl;
cin >> centerX;
cout << "Enter the y coordinate for the center of the circle. \n" << endl;
cin >> centerY;
cout << "Now enter the x coordinate for any point on the circle. \n" << endl;
cin >> pointX;
cout << "Now enter the y coordinate for any point on the circle. \n" << endl;
cin >> pointY;

radiusMain = radius(centerX, centerY, pointX, pointY);
diameterMain = diameter(radius);
circumferenceMain = circumference(radius);
areaMain = area(radius);

cout << "The radius of the circle is " << radiusMain << endl;
cout << "The diameter of the circle is " << diameterMain << endl;
cout << "The circumference of the circle is " << circumferenceMain << endl;
cout << "The area of the circle is " << areaMain << endl;

return 0;

}


double radius(double x, double y, double xs, double ys)
{
double radiusfunc;
radiusfunc = sqrt(pow((x-xs),2) + pow((y-ys),2));

return radiusfunc;
}


double diameter(double x)
{ double diameterfunc;
diameterfunc = x * 2;

return diameterfunc;
}

double circumference(double x)
{
double circumferencefunc;
circumferencefunc = 2 * pi * x;

return circumferencefunc;
}

double area(double x)
{
double areafunc;
areafunc = pi * pow(x,2);

return areafunc;
}
closed account (D80DSL3A)
The error messages you are getting tell you enough to figure out what is wrong. Look at the name of the argument you are passing to the functions on lines 39, 40 and 41.
1
2
3
diameterMain = diameter(radius);
circumferenceMain = circumference(radius);
areaMain = area(radius);

you got 3 argument problem.radius is a function name not a variable name.
and you may change it to:
1
2
3
diameterMain = diameter(radiusMain);
circumferenceMain = circumference(radiusMain);
areaMain = area(radiusMain);

this code compile and works fine:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <cmath>

using namespace std;

double radius(double x, double y, double xs, double ys);
double diameter(double x);
double circumference(double x);
double area(double x);

const double pi = 3.141;

int main()

{
double centerX;
double centerY;
double pointX;
double pointY;
double radiusMain;
double diameterMain;
double circumferenceMain;
double areaMain;

cout << "This program will calculate the radius, diameter, circumference and area \n of a circle if the user gives the locaction of the center point and \n a point on the circle."<< endl;
system("pause");
system("cls");

cout << "Enter the x coordinate for the center of the circle. \n" << endl;
cin >> centerX;
cout << "Enter the y coordinate for the center of the circle. \n" << endl;
cin >> centerY;
cout << "Now enter the x coordinate for any point on the circle. \n" << endl;
cin >> pointX;
cout << "Now enter the y coordinate for any point on the circle. \n" << endl;
cin >> pointY;

radiusMain = radius(centerX, centerY, pointX, pointY);
diameterMain = diameter(radiusMain);
circumferenceMain = circumference(radiusMain);
areaMain = area(radiusMain);

cout << "The radius of the circle is " << radiusMain << endl;
cout << "The diameter of the circle is " << diameterMain << endl;
cout << "The circumference of the circle is " << circumferenceMain << endl;
cout << "The area of the circle is " << areaMain << endl;

return 0;

}


double radius(double x, double y, double xs, double ys)
{ 
double radiusfunc;
radiusfunc = sqrt(pow((x-xs),2) + pow((y-ys),2));

return radiusfunc;
}


double diameter(double x)
{ double diameterfunc;
diameterfunc = x * 2;

return diameterfunc;
}

double circumference(double x)
{ 
double circumferencefunc;
circumferencefunc = 2 * pi * x;

return circumferencefunc;
}

double area(double x)
{
double areafunc;
areafunc = pi * pow(x,2);

return areafunc;
}
Topic archived. No new replies allowed.