设计模式-关于Decorator模式以及Proxy模式的一个疑问
碎碎念 2012-12-20 10:17:07 在Decorator模式的实现中,类Decorator本身已经维护了一个Component指针,为什么还有继承自Component?Decorator和Component用共同的函数接口Operation(),但是我觉得在该模式的实现中,这两个类的Opeation()只是名字相同,在Decorator的派生类ConcreteDecorator的Operation()调用的是基类Decorator中的Compent成员的Operation(),这两个Operation()没有直接继承关系,只是名字相同。。。
那为什么要让Decorator继承自Component?
在Proxy模式中也有同样的疑问,为什么让Proxy类也继承自Subject类?