递归调用被继承的基类成员函数,实现求素数的功能
#include <iostream>
using namespace std;
#define N 3.14
class Cylinder
{
private:
double a,b;
public:
Cylinder(double c1,double c2){a=c1;b=c2;}
double vol();
};
double Cylinder::vol()
{
return N*a*a*b;
}
int main()
{
Cylinder v(2,3);
cout<<"vol="<<v.vol()<<endl;
return 0;
}