Please Help. So far this is my program. #include using namespace std; class Poin
ID: 3633651 • Letter: P
Question
Please Help. So far this is my program.
#include
using namespace std;
class Point
{
public:
int x, y;
};
ostream& operator<<(ostream& out, Point&);
class Circle
{
private:
double radius;
Point centerPoint;
public:
Circle(double, int,int);
Circle(const Circle&other);
Circle operator=(constCircle& other);
double getRadius();
Point getCenter();
voidsetRadius(double);
void setCenter(int,int);
voidsetCenter(Point);
ostream&print(ostream& out);
};
ostream& operator<<(ostream& out, Point& p)
{
out << "(" << p.x << ", "<< p.y << ")";
return out;
}
Circle::Circle(double rad, int x, int y)
{
radius = rad;
centerPoint.x = x;
centerPoint.y = y;
}
Circle::Circle(const Circle& other)
{
radius = other.radius;
centerPoint.x = other.centerPoint.x;
centerPoint.y = other.centerPoint.y;
}
Circle Circle::operator=(const Circle& other)
{
radius = other.radius;
centerPoint.x = other.centerPoint.x;
centerPoint.y = other.centerPoint.y;
}
double Circle::getRadius()
{
return radius;
}
Point Circle::getCenter()
{
return centerPoint;
}
void Circle::setRadius(double n)
{
radius = n;
}
void Circle::setCenter(int x, int y)
{
centerPoint.x = x;
centerPoint.y = y;
}
void Circle::setCenter(Point other)
{
centerPoint.x = other.x;
centerPoint.y = other.y;
}
ostream& Circle::print(ostream& out)
{
Point p = getCenter();
out << "This circle has a radius of "<< getRadius();
out << " and is centered at point ";
out << p << endl;
return out;
}
Line 22, 26, 28, 55, 14, 72, 78, and 83 have compiling issues if put into C++ environment any help so it compiles would be appreciated.
Explanation / Answer
First of all in this program there is no void main() function.
Rest of the errors are suggest by arrow
#include<iostrea.h> -------------- include the header file
using namespace std; --------------- Remove namespace, delete the line
class Point
{
public:
int x, y;
};
ostream& operator<<(ostream& out, Point&);
class Circle
{
private:
double radius;
Point centerPoint;
public:
Circle(double, int,int);
Circle(const Circle&other);
Circle operator=(constCircle& other); ---------------------------------- remove return type like write
only operator=(const Circle & other)
and also space between const and Circle
double getRadius();
Point getCenter();
voidsetRadius(double); --------------------------------------------void space setRadius
void setCenter(int,int);
voidsetCenter(Point); --------------------------------------------------void space setCenter
ostream&print(ostream& out);
};
ostream& operator<<(ostream& out, Point& p)
{
out << "(" << p.x << ", "<< p.y << ")";
return out;
}
Circle::Circle(double rad, int x, int y)
{
radius = rad;
centerPoint.x = x;
centerPoint.y = y;
}
Circle::Circle(const Circle& other)
{
radius = other.radius;
centerPoint.x = other.centerPoint.x;
centerPoint.y = other.centerPoint.y;
}
Circle Circle::operator=(const Circle& other) -----------------------------------remove first Circle
{
radius = other.radius;
centerPoint.x = other.centerPoint.x;
centerPoint.y = other.centerPoint.y;
}
double Circle::getRadius()
{
return radius;
}
Point Circle::getCenter()
{
return centerPoint;
}
void Circle::setRadius(double n)
{
radius = n;
}
void Circle::setCenter(int x, int y)
{
centerPoint.x = x;
centerPoint.y = y;
}
void Circle::setCenter(Point other)
{
centerPoint.x = other.x;
centerPoint.y = other.y;
}
ostream& Circle::print(ostream& out)
{
Point p = getCenter();
out << "This circle has a radius of "<< getRadius();
out << " and is centered at point ";
out << p << endl;
return out;
}