Home > Back-end >  Why couldn't run the program?
Why couldn't run the program?

Time:10-06

Classes define a Circle (Circle), the radius attribute (radius), circumference and area of operation for the input radius and calculate the perimeter, area, output radius, pupil, requirements definition constructor (with radius parameters, pupil in the constructor generated), and all the member functions in the test class
#include
using namespace std;
The class Circle
{
Private: float radius, circum, area;
Public: Circle (radius, float);
};
Circle: : Circle (float raidus)
{circum=2 * 3.14 * radius;
Radius, area=3.14 * * radius;
cout <"The radius=" & lt; Cout<& lt;" Circum="& lt; Cout<& lt;" Area="& lt; }
Int main ()
{
Float the radius;
cout <"Both please enter the radius:" & lt; cin> The radius.
Circle circle1 (radius);
return 0;
}

CodePudding user response:

Dizzy, parameters and members of the same name, use this to distinguish, namely
This - & gt; The radius=raidus;//add here
Circum=2 * 3.14 * radius;//in front of it with the code above

CodePudding user response:

reference 1st floor qybao response:
, parameters and members of the same name, use this to distinguish, namely
This - & gt; The radius=raidus;//add here
Circum=2 * 3.14 * radius;//in front of the combined with the above code

Thank you, thank you

CodePudding user response:

Such inappropriate design class

It is ok to only a radius attribute
The calculation of other dynamic
GetArea () {return radius radius, * * PI; }

  • Related