#include <iostream>
using namespace std;
class Box
{
// 受保护的
protected:
double width;
};
class SmallBox:Box // SmallBox是派生类
{
// 公有的
public:
void setSmallWidth(double wid);
double getSmallWidth(void);
};
// 子类的成员函数
double SmallBox::getSmallWidth(void)
{
return width;
}
void SmallBox::setSmallWidth(double wid)
{
width = wid;
}
int main()
{
SmallBox box;
box.setSmallWidth(6.0);
cout << "Width of box:" << box.getSmallWidth() << endl;
system("pause");
return 0;
}