Home > Back-end >  C create classes and is often a member function
C create classes and is often a member function

Time:05-28

Write this code without error, but also show run successfully, but I feel the result of the outbreak is problematic, I don't have to enter, why will have to input values and, no matter how much input the final values are the same, thanks and have a great god can help solve

CodePudding user response:

Your code?

CodePudding user response:

No code, no truth,

CodePudding user response:

#include #include # define PI 3.141592 using namespace STD. Class Point {private: double x, y; Public: Point (double x_=0, double y_=0) : x (y_) {}; Double GetX (); Double GetY (); Void Change (int a, int b); Void the print (); Void the print () const; Friend a double Area (const Point& , Point&); }; Double Point: : GetX () {return x; } double Point: : GetY () {return y; } void Point: : Change (int a, int b) {double x0, y0. Cin> X0 & gt;> Y0. X=x0; Y=y0; {} void Point: : print () cout<& lt;" (" CodePudding user response:

I resend the post bar again

CodePudding user response:

Reference:
 # include 
#include
# define PI 3.141592
using namespace std;

The class Point {
Private: double x, y;
Public: Point (double x_=0, double y_=0) : x (x_), y (y_) {};//, y (y_)
Double GetX () const;
Double GetY () const;
Void Change (int a, int b);
Void the print ();
Void the print () const;
Friend a double Area (const Point& , Point&);
};
Const double Point: : GetX ()
{
Return the x;
}
Const double Point: : GetY ()
{
The return of y;
}
The void Point: : Change (int a, int b)
{
//double x0, y0;
//cin> X0 & gt;> Y0.
//x=x0;
//y=y0;
X=a;
Y=b;
}
The void Point: : print ()
{
Cout<& lt;" ("}
The void Point: : print () const
{
Cout<& lt;" ("}
Double Area (const Point & amp; P1, Point & amp; P2)
{
Double r;
R=SQRT ((p1) X-ray p2) x) * (p1) X-ray p2) x) + (p1) y - p2) y) * (p1) y - p2) y));
return PI*r*r;
//cout}
Int main ()
{
Const Point p1.
P1. The print ();
Point p2 (5, 3);
P2. Print ();
Cout<& lt;" S1="& lt;
P2. Change (56, 34);
P2. Print ();
Cout<& lt;" S1="& lt;
return 0;
}

//(0, 0)

///(5, 3)

//s1=106.814
//(56, 34)

//s1=13483.7
//please press any key to continue...
  • Related