C++新手请教一个问题,谢谢。

A_la_n 2015-06-28 03:39:07
今天在联系的时候写了这么个东西,但是一直有错误不知道是怎么回事。请帮忙看看,谢谢。
# include <iostream>
# include <string>
using namespace std;

class Building { //基本信息
public:
float LCS;
float FJS;
float ZMJ;

};

class Home : public Building {

public:
int WSS;
int KTS;
int WSJS;
int CFS;
void add1(float lcs,float fjs, float zmj, int wss, int kts, int wsjs, int cfs);


};

void Home::add1(float lcs, float fjs, float zmj,int wss, int kts, int wsjs, int cfs) {


LCS =lcs;
FJS =fjs;
ZMJ=zmj;
WSS=wss;
KTS=kts;
WSJS=wsjs;
CFS=cfs;
cout<<"住宅楼:"<<endl;
cout<<" 楼层数:"<<lcs<<" "<<"层"<<endl;
cout<<" 房间数:"<<fjs<<" "<<"间"<<endl;
cout<<" 楼房总面积:"<<zmj<<" "<<"平方米"<<endl;
cout<<"其中:\n";
cout<<" 卧室数:"<<wss<<" "<<"间"<<endl;
cout<<" 客厅数:"<<kts<<" "<<"间"<<endl;
cout<<" 卫生间数数:"<<wsjs<<" "<<"间"<<endl;
cout<<" 厨房数:"<<cfs<<" "<<"间"<<endl<<endl<<endl;
}

class Office:public Building {

public:
int BGSS;
int HYSS;

void add2(float lcs, float fjs, float zmj, int bgss,int hyss);


};
void Office::add2(float lcs, float fjs, float zmj, int bgss,int hyss){
LCS =lcs;
FJS =fjs;
ZMJ=zmj;
BGSS=bgss;
HYSS=hyss;
cout<<"办公室:"<<endl;
cout<<" 楼层数:"<<lcs<<" "<<"层"<<endl;
cout<<" 房间数:"<<fjs<<" "<<"间"<<endl;
cout<<" 楼房总面积:"<<zmj<<" "<<"平方米"<<endl;
cout<<"其中:"<<endl;
cout<<" 办公室数:"<<bgss<<" "<<"间"<<endl;
cout<<" 会议室数:"<<hyss<<" "<<"间"<<endl<<endl<<endl;


class Hospital:public Building {

public:
int BFS;
int Shoushu;


void add3(float lcs, float fjs, float zmj, int bfs,int shoushu);


};

void Hospital::add3(float lcs, float fjs, float zmj, int bfs,int shoushu) {
//存入对象数组中

LCS =lcs;
FJS =fjs;
ZMJ =zmj;
BFS=bfs;
Shoushu=shoushu;
cout<<"医院:"<<endl;
cout<<" 楼层数:"<<lcs<<" "<<"层"<<endl;
cout<<" 房间数:"<<fjs<<" "<<"间"<<endl;
cout<<" 楼房总面积:"<<zmj<<" "<<"平方米"<<endl;
cout<<"其中:"<<endl;
cout<<" 病房数:"<<bfs<<" "<<"间"<<endl;
cout<<" 手术室数:"<<shoushu<<" "<<"间"<<endl;


}

int main ()
{

Home h;
Hospital ho;
Office off;
h.add1(1,2,3,4,5,6,7);
ho.add3(1,2,2,3,5);
off.add2(1,2,4,5,2);

return 0;
}
...全文
86 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Isnis-fallen 2015-06-28
  • 打赏
  • 举报
回复
add2 忘写 }

64,651

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧