app开发者平台在数字化时代的重要性与发展趋势解析
630
2022-11-18
组合和继承综合(9)
#ifndef#define#include
#include "display.h"display::display() { cout << "display::display()" << endl;}display::~display() { cout << "display::~display()" << endl;}void display::DoDisPlay() { cout << "display::DoDisPlay()" << endl;}
#ifndef#define#include
#include "Key.h"key::key() { cout << "key()" << endl;}key::~key() { cout << "~key()" << endl;}void key::DoKey() { cout << "key::DoKey()" << endl;}
#ifndef#define#include
#include "mouse.h"mouse::mouse() { cout << "mouse::mouse()" << endl;}mouse::~mouse() { cout << "mouse::~mouse()" << endl;}void mouse::DoMouse() { cout << "mouse::DoMouse()" << endl;}
#ifndef#define#include
#include "print.h"print::print() { cout << "print::print()" << endl;}print::~print() { cout << "print::~print()" << endl;}void print::DoPrint() { cout << "print::DoPrint()" << endl;}
#ifndef#define#include
#include "computer.h"#include "display.h"#include "Key.h"#include "mouse.h"#include "print.h"//派生出来的protect通过初始化列表进行初始化,我们这都是public可以不通过初始化列表初始化computer::computer() :display(), key(), Mouse(),Print(),x(5){ cout << "computer::computer()" << endl;}computer::~computer() { cout << "computer:~:computer()" << endl;}void computer::DoCpu() { cout << "computer::DoCpu() " << endl;}
#include "computer.h"#include "print.h"#include "display.h"#include "Key.h"#include "mouse.h"int main() { computer Computer; Computer.DoCpu(); Computer.DoDisPlay(); Computer.DoKey(); Computer.Mouse.DoMouse(); Computer.Print.DoPrint(); return 0;}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~