write a definition of a class named Point that might be used to store and manipulate the location of a point in the plane.

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. A member function to rotate the point by 90 degrees clockwise around the origin.

d. Two const inspector functions to retrieve the current coordinates of the point.

Here is what I have for code so far ... but I am kind of lost in getting it to shift point locations as desired and I am getting errors....

[
#include <iostream>
#include <cstdlib>

using namespace std;

class Point
{
public:
void initialize(double init_x, double init_y);
void shift(double dx, double dy);
double get_x();
double get_y();
private:
double x;
double y;

};

int main()
{
Point p1;
Point p2;

p1.initialize(-1.0, 0.8);
cout << p1.get_x() << p1.get_y() << endl;
p2.initialize(p1.get_x(),p1.get_y());
cout << p2.get_x() << p2.get_y() << endl;
p2.shift(1.3, -1.4);
cout << p2.get_x() << p2.get_y() << endl;

return 0;
}

void Point::initialize(double init_x, double init_y)
{
x = init_x;
y = init_y;
}

double Point::get_x()
{
return x;
}

void Point::shift(double dx, double dy)
{
x = x - y;
y = x;
}
]

I think this function

void Point::shift(double dx, double dy)

shoudl add dx to the x member and add dy to the y member.

As to errors, please post the exact error message (or pertinent parts thereof) and where in your code you think the problem lies.

When posting code, please use the tags

[code]

your code goes here

[/code]

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.