#include<iostream>
using namespace std;
class Cylinder
{
private:
float radius;
float high;
double volume;
public:
Cylinder();
double CalculateV();
void OutPut();
};
Cylinder::Cylinder()
{
float aradius,ahigh;
cin >> aradius >> ahigh;
radius = aradius;
high = ahigh;
}
double Cylinder::CalculateV()
{
volume = 3.14*radius*high;
}
void Cylinder::OutPut()
{
cout << "The volume of the cylinder is:" << volume;
}
int main()
{
Cylinder cylinder1;
Cylinder();
cylinder1.CalculateV();
cylinder1.OutPut();
}
各位大佬我想问一下,我这里为什么会要输入四个变量呢,我明明只定义了aradius和ahigh啊