i have tried so much to understnd this problem but can't able to get it.. plxx tell me how it will b solve or atleast give me syntax.!!
this is the header file that i had made..

// A 2-dimensional point class!
// Coordinates are double-precision floating point.
class Point 


  double x_coord;
  double y_coord;

  // Constructors
  Point();                              // default constructor
  Point(double x, double y);        // two-argument constructor
  double distanceto(Point&);
  // Destructor

  // Mutator methods
  void setX(double val);
  void setY(double val);

  // Accessor methods
  double getX();
  double getY();

// Default constructor:  initializes the point to (0, 0).
Point::Point() {
  x_coord = 0;
  y_coord = 0;

// Initializes the point to (x, y).
Point::Point(double x, double y) {
  x_coord = x;
  y_coord = y;

// Destructor - Point allocates no dynamic resources.
  // no-op

// Mutators:

void Point::setX(double val) {
  x_coord = val;

void Point::setY(double val) {
  y_coord = val;

// Accessors:

double Point::getX() {
  return x_coord;

double Point::getY() {
  return y_coord;


  1. Add a new member function to Point called distanceTo. This member function should accept as an argument a Point & (a reference to a Point), and it should return a double that approximates the distance between the two points.
    You will probably find a square-root function useful for this! The C standard library has one, called sqrt(). The function takes a double and returns another double.
    If you were programming in C, you would #include <math.h>, but in C++ you say #include <cmath>. (This means, "Include the C Math header.") And then you are all set.

    **3. In the Class_Lab.cpp file with int main() **

Prompt the user for the coordinates of two points and return the distance between the two points they give you.
In C++, you don't have to declare all variables at the top of a block; you can intermingle variable declarations and statements of code. So, you should only need to use three double variables to input the coordinates, and then create each Point along the way.


Which part don't you understand? The instructions are very explicit, though there's an assumption that you'll figure out how to calculate the distance between two points. I would expect a programming instructor to at least remind the class that the distance between two points can be solved with an equivalence of the Pythagorean theorem:

double a = a.getX() - b.getX();
double b = a.getY() - b.getY();
double c = sqrt(a * a + b * b);
This article has been dead for over six months. Start a new discussion instead.