//13.2 抽像类与体类(Abstract & Concrete Classes)
//只要子类中尚有未被覆盖定义的纯虚函数,那么,子类相对于抽像基类的抽像状态不变//该类继承结构由下列程序代码实现之:#includeclass Display{public: virtual void inint()=0; virtual void write(char* pStr)=0;};//定义两个纯虚函数class Monochrome : public Display{ virtual void inint(); //覆盖 virtual void write(char* pStr); //覆盖};void Monochrome::inint(){ };void Monochrome::write(char* pStr){ std::cout<<"Monochrome: "< <<"\n";};class ColorAdapter : public Display{public: virtual void write(char* pStr); //覆盖 };void ColorAdapter::write(char* pStr){ std::cout<<"ColorAdapter: "< <<"\n";}class SVGA : public ColorAdapter{public: virtual void inint(); //覆盖};void SVGA::inint(){ }void g(Display* d){ d->inint(); d->write("hello.");}int main(){ std::cout<<"I am main\n"; Monochrome mc; SVGA svga; g(&mc); g(&svga); system("pause"); return 0;}