#include <iostream.h>
class Building
{
private:
int floor;
int room;
float area;
public:
Building(int f,int r,float a)
{
floor=f;
room=r;
area=a;
}
virtual void show()
{
cout<<"楼房的层数:"<<floor<<"房间数:"<<room<<"总平方数:"<<area<<endl;
}
};
class House:public Building
{
private:
int bedroom;
int bathroom;
public:
House(int be,int ba)
{
bedroom=be;
bathroom=ba;
}
void show()
{
cout<<"卧室的数量:"<<bedroom<<"浴室的数量:"<<bathroom<<endl;
}
};
class Office:public Building
{
private:
int fire;
int telephone;
public:
Office(int fi,int te)
{
fire=fi;
telephone=te;
}
void show()
{
cout<<"灭火器的数量:"<<fire<<"电话的数量:"<<telephone<<endl;
}
};
void main()
{
Building B(3,5,100),*p;
House H(3,2);
Office O(5,6);
p=&B;
p->show();
p=&H;
p->show();
p=&O;
p->show();
}
error C2512: 'Building' : no appropriate default constructor available
为什么会出现这个
MadMarical
相关分类