[SEE 1ST COMMENT]
I am getting the following errors when I add the code associated with the "findArea" and "findCircumference":
(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(57): error C2556: 'int Circles::findArea(float)' : overloaded function differs only by return type from 'double Circles::findArea(float)'
(10) : see declaration of 'Circles::findArea'
(57): error C2371: 'Circles::findArea' : redefinition; different basic types
(10) : see declaration of 'Circles::findArea'
(58): error C2064: term does not evaluate to a function taking 1 arguments
(62): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(62): error C2556: 'int Circles::findCircumference(float)' : overloaded function differs only by return type from 'double Circles::findCircumference(float)'
(11) : see declaration of 'Circles::findCircumference'
(62): error C2371: 'Circles::findCircumference' : redefinition; different basic types
(11) : see declaration of 'Circles::findCircumference'
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
|
#include <iostream>
using namespace std;
class Circles
{
public:
Circles(); // Default constructor
Circles(float r, int x, int y); // Constructor
void printCircleStats(); // This outputs the radius and center of the circle.
double findArea(float);
double findCircumference(float);
private:
float radius;
int center_x;
int center_y;
};
const double PI = 3.14;
int main()
{
Circles sphere(8, 9, 10);
sphere.printCircleStats();
cout << "The area of the circle is " << sphere.findArea(8) << "\n";
cout << "The circumference of the circle is " << sphere.findCircumference(8) << "\n";
system("Pause");
return 0;
}
Circles::Circles()
{
radius = 1;
center_x = 0;
center_y = 0;
}
Circles::Circles(float r, int x, int y)
{
radius = r;
center_x = x;
center_y = y;
}
void Circles::printCircleStats()
// This procedure prints out the radius and center coordinates of the circle
// object that calls it.
{
cout << "The radius of the circle is " << radius << endl;
cout << "The center of the circle is (" << center_x
<< "," << center_y << ")" << endl;
}
Circles::findArea(float r)
{
return PI(r * 2);
}
Circles::findCircumference(float r)
{
return 2 * PI * r;
}
|