cylindr1.cpp
来自「经典vc教程的例子程序」· C++ 代码 · 共 29 行
CPP
29 行
// Fig. 10.2: cylindr1.cpp
// Member and friend function definitions for class Cylinder
#include "cylindr1.h"
Cylinder::Cylinder( double h, double r, int x, int y )
: Circle( r, x, y ) // call base-class constructor
{ setHeight( h ); }
void Cylinder::setHeight( double h )
{ height = h > 0 ? h : 0; }
double Cylinder::getHeight() { return height; }
double Cylinder::area() const
{
// surface area of Cylinder
return 2 * Circle::area() +
2 * 3.14159 * getRadius() * height;
}
double Cylinder::volume() const
{ return Circle::area() * height; }
void Cylinder::print() const
{
Circle::print();
cout << "; Height = " << height;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?