Question: Define a Point class. The class has two private floating point data members: x, point in a two-dimensional space. The class has the following public
Define a Point class. The class has two private floating point data members: x, point in a two-dimensional space. The class has the following public member functions:
y, the coordinate of a - One default constructor takes no parameter and sets the value of x, y to 0.
-
- One constructor takes two parameters and sets the value of x, parameters.
-
- A function, setX(float xc) sets the value of x to xc.
-
- A function, setY(float yc) sets the value of y to yc.
-
- A function, getX()const returns the value of X.
-
- A function, getY()const returns the value of y.
y to the corresponding
a. Define Point class. b. Implement all the member functions. c. Write a free (or friend or member) function to overload operator+, which returns the distance
between two Point objects. i.e. this following code will be allowed if operator+ is overloaded according to such specification.
Point p1, p2; int dist;
dist = p1 + p2; cout << The distance between p1 and p2 is << dist << endl;
d. Write a main function to test your class definition and all its member functions and the operator overloading function.
language: C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
