The type Point is a fairly simple data type that represents a point in the
two-dimensional plane. Write a definition of a class named Point that might be used
to store and manipulate the location of a point in the plane. You will need to declare
and implement the following member functions:
(a) a member function set that sets the private data after an object of this class is
created.
(b) a member function to move the point by an amount along the vertical and
horizontal directions specified by the first and second arguments.
(c) two const functions to retrieve the current coordinates of the point.
Embed your class in a test program that requests data for several points from the user,
creates the points, then exercises the member functions.
Document these functions with appropriate comments. embed your class in a test program that request data for several points from the user ,creates the points , then exercises the member functions.

so for I had this

#include <iostream>
#include <cmath>
using namespace std;

class Point
{
public:
Point(double initial_x = 0, double initial_y = 0);
void shift(double x_amount, double y_amount);
void rotate90();
int rotation_needed(Point p);
void rotation_upper_right(Point &p);

double get_x() const {return x;}
double get_y() const {return y;}

friend istream& operator >>(istream &ins, Point &target);

private:
double x;
double y;
};

//NON-MEMBER FUNCTIONS
double distance(const Point &p1, const Point &p2);
Point mid_point(const Point &p1, const Point &p2);
bool operator ==(const Point &p1, const Point &p2);
bool operator !=(const Point &p1, const Point &p2);
Point operator +(const Point &p1, const Point &p2);
ostream& operator <<(ostream &outs, const Point &source);


Point::Point(double initial_x, double initial_y)
{
x = initial_x;
y = initial_y;
}

void Point::shift(double x_amount, double y_amount)
{
x += x_amount;
y += y_amount;
}

void Point::rotate90()
{
double new_x;
double new_y;

new_x = y;
new_y = -x;
x = new_x;
y = new_y;
}

int Point::rotation_needed(Point p)
{
int answer = 0;
while((p.get_x() < 0) || (p.get_y() < 0))
{
p.rotate90();
answer++;
}
return answer;
}

void Point::rotation_upper_right(Point &p)
{
while((p.get_x() < 0) || (p.get_y() < 0))
{
p.rotate90();
}
}

double distance(const Point &p1,const Point &p2)
{
double a, b, c_square;
a = p1.get_x() - p2.get_x();
b = p1.get_y() - p2.get_y();
c_square = a*a + b*b;

return (sqrt(c_square));
}

Point mid_point(const Point& p1, const Point& p2)
{
double x_midpoint, y_midpoint;

x_midpoint = (p1.get_x() + p2.get_x()) / 2;
y_midpoint = (p1.get_y() + p2.get_y()) / 2;

Point midpoint(x_midpoint, y_midpoint);
//construct new object midpoint with values of x_midpoint and y_midpoint

return midpoint;
}

bool operator ==(const Point &p1, const Point &p2)
{
return ((p1.get_x() == p2.get_x()) && (p1.get_y() == p2.get_y()));
}

bool operator !=(const Point &p1, const Point &p2)
{
return (!(p1 == p2));
}

Point operator +(const Point &p1, const Point &p2)
{
double x_sum, y_sum;
x_sum = p1.get_x() + p2.get_x();
y_sum = p1.get_y() + p2.get_y();

Point sum(x_sum, y_sum);
return sum;
}

ostream& operator <<(ostream &outs, const Point &source)
{
outs << source.get_x() << " " << source.get_y();
return outs;
}

istream& operator >>(istream &ins, Point &target)
{
ins >> target.x >> target.y;
return ins;
}

I have some linking problems

Such as?

> What exactly are you trying to do?

> Are you creating a class library?
=> In this case you'll have to compile it to object code first and after that you can create a library from it ...
> Are you writing a stand-alone program?
=> In this case you'll have to add a main() function to your program, you know:

int main()
{
    /* Your code here */
    return 0;
}

> What compiler/IDE are you using ?

P.S.: I can confirm that with me your code compiles perfectly, without any warnings or errors, I'm using the Borland Compiler ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.