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

📄 f1006.cpp

📁 it is a usefull thing
💻 CPP
字号:
//=====================================
// f1006.cpp
// 多重继承
//=====================================
#include<iostream>
using namespace std;
//-------------------------------------
class Bed{
protected:
  int weight;
public:
  Bed():weight(0){}
  void sleep()const{ cout <<"Sleeping...\n"; }
  void setWeight(int i){ weight =i; }
};//-----------------------------------
class Sofa{
protected:
  int weight;
public:
  Sofa():weight(0){}
  void watchTV()const{ cout <<"Watching TV.\n"; }
  void setWeight(int i){ weight =i; }
};//-----------------------------------
class SleeperSofa : public Bed, public Sofa{
public:
  SleeperSofa(){}
  void foldOut()const{ cout <<"Fold out the sofa.\n"; }
};//-----------------------------------
int main(){
  SleeperSofa ss;
  ss.watchTV();
  ss.foldOut();
  ss.sleep();
}//====================================

 

⌨️ 快捷键说明

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