#include <iostream>
using namespace std;
class Building
{
protected:
int m_nFloorNum; // 层数
int m_nRoomNum; // 房间数
int m_nArea; // 总平方米数
public:
Building()
{
m_nFloorNum = 0;
m_nRoomNum = 0;
m_nArea = 0;
}
Building(int nFloorNum, int nRoomNum, int nArea)
{
m_nFloorNum = nFloorNum;
m_nRoomNum = nRoomNum;
m_nArea = nArea;
}
virtual ~Building()
{
}
void OutputInfo()
{
cout<<"层数:"<<m_nFloorNum<<endl;
cout<<"房间数:"<<m_nRoomNum<<endl;
cout<<"总平方米数:"<<m_nArea<<endl;
}
};
class House : public Building
{
protected:
int m_nBedroomNum; // 卧室数
int m_nBathroomNum; // 浴室数
public:
House()
{
m_nBedroomNum = 0;
m_nBathroomNum = 0;
}
House(int nFloorNum, int nRoomNum, int nArea, int nBedroomNum, int nBathroomNum)
: Building(nFloorNum, nRoomNum, nArea)
{
m_nBedroomNum = nBedroomNum;
m_nBathroomNum = nBathroomNum;
}
virtual ~House()
{
}
void OutputInfo()
{
Building::OutputInfo();
cout<<"卧室数:"<<m_nBedroomNum<<endl;
cout<<"浴室数:"<<m_nBathroomNum<<endl;
}
};
class Office : public Building
{
protected:
int m_nDeskNum; // 办公桌数
int m_nPhoneNum; // 电话数
public:
Office()
{
m_nDeskNum = 0;
m_nPhoneNum = 0;
}
Office(int nFloorNum, int nRoomNum, int nArea, int nDeskNum, int nPhoneNum)
: Building(nFloorNum, nRoomNum, nArea)
{
m_nDeskNum = nDeskNum;
m_nPhoneNum = nPhoneNum;
}
virtual ~Office()
{
}
virtual void OutputInfo()
{
Building::OutputInfo();
cout<<"办公桌数:"<<m_nDeskNum<<endl;
cout<<"电话数:"<<m_nPhoneNum<<endl;
}
};
///
int main(int argc, char* argv[])
{
House house1;
house1.OutputInfo();
cout<<endl;
House house2(7, 28, 2800, 84, 28);
house2.OutputInfo();
cout<<endl;
Office office1;
office1.OutputInfo();
cout<<endl;
Office office2(3, 12, 1200, 36, 36);
office2.OutputInfo();
cout<<endl;
return 0;
}