Home > Back-end >  The small white consult
The small white consult

Time:09-22

Point class is used to describe a Point on the plane, short classes are used to describe the Distance between two points, its data members include two Point class object, calculate the Distance between two points,
Reference:
# include
#include
using namespace std;
The class Point
{
Int x, y;
Public:
Set_xy (int a=0, int b=0) {x=a; Y=b; }
Int xcord () {return x; }
Int ycord () {return y; }
};
The class short
{
Point p1, p2,
Double dist.
Public:
Short (Point q1, Point q2)
{
P1=q1;
The p2=q2;
Double x=double (p1. Xcord () - p2. Xcord ());
Double y=double (p1) ycord () - p2. Ycord ());
Dist=SQRT (x * * y x + y);
}
Double getdist () {return dist. }
};
Int main ()
{
Point p, q;
P. et_xy ();
Q.S et_xy (1, 1);
Short dis (p, q);
cout<" The short is: "& lt;
return 0;
}
On the basis of the above program, put Set_xy function constructor is used to implement the function of, to rewrite the program and use the computer to run the program,

CodePudding user response:

Is to implement the following Point's constructor, may have to achieve something else such as copy construction, etc.,

CodePudding user response:

reference 1/f, Simple, Soft reply:
is to implement the following Point's constructor, may also implement some other copy construction, etc, for example,

Who can help you to write a program yao
  • Related