# include
using namespace std;
Const float PI=3.14;
The class shape {
Private:
Int x;
Int y;
Virtual float GetArea ()=0;
};
Class a Rectangle: public shape {
Public:
Virtual float GetArea ()
{
Return the length * width;
}
Void the set (int a, int b)
{
This - & gt; Length=a;
This - & gt; Width=b;
}
Int length;
Int width;
};
The class Circle: public shape {
Public:
Void the set (int r)
{
This - & gt; Circle_r=r.
}
Virtual float GetArea ()
{
Return PI * Circle_r * Circle_r;
}
Private:
Int Circle_r;
};
The class Square: public Rectangle {
Public:
Void the set (int lenth1)
{
This - & gt; Length1=length1;
}
Virtual float GetArea ()
{
Return length1 ^ 2;
}
Int length1;
};
Int main ()
{
int a,b;
Cin> A> b;
A Rectangle s;
S.s et (a, b);
cout
Int r;
Cin> r;
Circle s1.
S1. Set (r);
cout
int m;
Cin> m;
Circle s2.
S2. Set (m);
cout
return 0;
system("pause");
}
Input output shows through, theory circle radius 10, the output of the area should be 314, the actual output is 31478.5, please reply
CodePudding user response:
No pictures without the truth!CodePudding user response:
As if no mistake, leaving only the code youInt r;
Cin> r;
Circle s1.
S1. Set (r);
cout
This period of running a try, as a separate operation of debugging
CodePudding user response:
To debug it and see whyIf don't know much about debugging, refer to the
https://edu.51cto.com/sd/c4099
CodePudding user response:
VS2015 c + + environment, debugging
CodePudding user response:

Is the use of cattle from online programming test, the result is as follows
CodePudding user response:
Using VS compiler tried
Finally the square area of results should be overflow or? Don't know where is wrong, ask bosses solutions

CodePudding user response:
Dev - c + + 5.11 test result


The above two groups of test no problem
The original poster running environment is what?
CodePudding user response:
SeeThe building Lord input method is the following the

Because, the two did not set the symbol is separated, the output of the circular area in 314 and 78.5 together
Into 31478.5
CodePudding user response:
Thank you bosses solutions, small new understood; I am trying to build a square area, the output should be 16, the result isint m;
Cin & gt;> m;
Square s2;
S2. Set (m);
Cout & lt;![]()
Did not understand,,,,?????