摘要:
//13.7.1 对像指针问题(Object Pointer Problem)//13.7.2 对像指针的外套(The Coat of Object Pointer)//Sony Handle的应用/*#include "createsony.h"#include "sonyhandle.h"#include <iostream>enum{PUREFLAT, PLASMA, LIQUIDCRYSTAL, NANOMETER};void fsh(SonyHandle& sh){sh->adjustVolume();sh->s 阅读全文
摘要:
#include "createsony.h"#include "sony.h"enum Technology{PUREFLAT,PLASMA,LIQUIDCRYSTAL,NANOMETER};void fn(Sony* s){ Sony2 * ps2 = dynamic_cast<Sony2*>(s); //增加 if(ps2) ps2->adjustLight(); //否则不用 ps2->adjustVolume(); ps2->switchChannel();}void createSonyObject(Create 阅读全文
摘要:
//13.6 系统扩展(System Extension)//13.6.1 新添加一个界面(Adding One Interface)//添加一个sony2.h 做为调整亮度的操作,他继承者sony.h//由Sony派生Sony2#include "createsony.h"#include "sony.h"enum Technology{PUREFLAT,PLASMA,LIQUIDCRYSTAL};void fn(Sony* s){ Sony2 * ps2 = dynamic_cast<Sony2*>(s); //增加 if(ps2) ps 阅读全文
摘要:
//13.5.1 面向对像的模块(Object-Oriented Module)//13.5.2 Sony类层次结构(Class Sony Hierarchy)//纯平(PureFlat) 等离子(Plasma) 液晶(Liquid Crystal)//例如,若等离子类中有公共操作"等离子图像变换",我们在fn函数中获得了Sony类指针,并确认为等离子29英寸电视机,于是进行以下操作/*void fn(Sony* sp){ B29* b = dynamic_cast<B29*>(sp); if(b) b->切换频道(); //okPlasma* p = d 阅读全文