#include<iostream> using namespace std; #define p 3.1415926 class Cylinder { private: double v; public: Cylinder(double r = 0,double h = 0) { v = p * r * r * h; } double vol() { return v; } }; int main() { class Cylinder vr(1,1); cout<<"vr ="<< vr.vol(); return 0; }
原文:http://blog.csdn.net/cherry_ermao/article/details/44524275