Home > Back-end >  C problem answer, thank
C problem answer, thank

Time:11-06

Declare a Circle, data members for the radius, a member function with constructor parameters, for the function of Circle area, new type of Cylinder by the Circle of public derived class class, the derived class data members for the heigth, a member function with parameter constructor, the volume of a cylindrical function; the main function is defined in a Cylinder of the object, the given radius and high, then output the volume of a Cylinder,

CodePudding user response:

Problem of c + + code, heavily reward!

CodePudding user response:

#include
# define PI 3.14

using namespace std;

The class Circle
{
Public:
Circle radius, (int) {radius=radius; }
Circle, Circle & amp; C);
~ Circle () {}
Int GetRadius () {return Radius; }
Const int GetArea ();

Private:
Int the Radius;

};

Circle: : Circle (Circle & amp; C) {
C.R adius=Radius;
}

Const int Circle: : GetArea () {
Radius, return PI * * Radius;
}

Int main ()
{
int r;
Circle the demo (3);
cout <"Is the area of the" demo (3) & lt;
cout <"Please enter a circle of radius r=";
cin> r;
Circle not (r);
cout <"Not (r) is the area of the" & lt; return 0;
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (ptspzy) of the original articles, follow BY CC 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/ptspzy/article/details/46497457
  • Related