⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8-12.cpp

📁 为初学者提供的最佳的C++程序设计源程序库
💻 CPP
字号:
#include<iostream.h>
#include<iomanip.h>
class classroom
{
private:
  float longedge;
  float shortedge;
public:
  classroom(){}
  classroom(float loge,float shge)
  {
    longedge=loge;
	shortedge=shge;
  }
  void getlength()
  {
    cout<<"Input large edge:";
    cin>>longedge;
    cout<<"Input small edge:";
    cin>>shortedge;
  }
  void showsquare()
  {  
    cout<<setprecision(3)
        <<longedge*shortedge<<endl;
  }
  void addsquare(classroom r1,classroom r2);
  void addedge(classroom r1,classroom r2);
};
void classroom::addsquare(classroom r1,classroom r2)
{
  longedge=r1.longedge+r2.longedge;
  shortedge=r1.shortedge+r2.shortedge;
  cout<<"\n Total of classroom square:"
      <<r1.longedge*r1.shortedge+r2.longedge*r2.shortedge;
}
void classroom::addedge(classroom r1,classroom r2)
{
  longedge=r1.longedge+r2.longedge;
  shortedge=r1.shortedge+r2.shortedge;
  cout<<"\n Toatal of classroom length:"
      <<setprecision(3)<<(longedge+shortedge)*2;
}
main()
{
  classroom room1(15.5,6.5);
  classroom room2,room3;
  room2.getlength();
  cout<<"Square of room1 classroom is:";
  room1.showsquare();
  cout<<"square of room2 classroom is:";
  room2.showsquare();
  room3.addsquare(room1,room2);
  room3.addedge(room1,room2);
  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -