#include <iostream> using namespace std; class Memory{ public: void check(){ cout<<"内存自检"<<endl; } void off(){ cout<<"内存关闭"<<endl; } }; class Cpu{ public: void run(){ cout<<"CPU运行"<<endl; } void off(){ cout<<"CPU关闭"<<endl; } }; class HardDisk{ public: void read(){ cout<<"硬盘读取"<<endl; } void off(){ cout<<"硬盘关闭"<<endl; } }; class Os{ public: void load(){ cout<<"操作系统加载"<<endl; } void off(){ cout<<"操作系统关闭"<<endl; } }; class MainFrame{ private: Memory w1; Cpu w2; HardDisk w3; Os w4; public: void on(){ cout<<"开机中......"<<endl; w1.check(); w2.run(); w3.read(); w4.load(); } void off(){ cout<<"关机中......"<<endl; w1.off(); w2.off(); w3.off(); w4.off(); } }; int main(){ MainFrame w; w.on(); w.off(); return 0; }
标签:std,外观,cout,void,模式,check From: https://www.cnblogs.com/qiuyutingyyds/p/16855734.html