On Wednesday 06 March 2002 23:56, Carsten Pfeiffer wrote: > On Sunday 03 March 2002 22:17, Martijn Klingens wrote: > > > Would it be a good idea to use the Template Method pattern instead that > > Dawit mentioned on kde-cvs last week? That might be even more flexible. > > What the API would be like then is > > > > public: > > bool openStream() { return doOpenStream(); } > > bool writeStream( const QDataStream &s ) { return doWriteStream( s ); } > > bool closeStream() { return doCloseStream(); } > > private: > > virtual bool doOpenStream() { return false; } > > virtual bool doWriteStream( const QDataStream& ) { return false; } > > virtual bool doCloseStream() { return false; } > > There's a drawback in that pattern tho. Imagine you inheriting some other > part, needing to reimplement the virtual methods. Whoops, you can't call the > baseclass' implementation anymore. The topmost superclass is fine, as it has > the non-virtual method, but the one(s) in the middle "dry out". Doesn't s/private/protected/ (in the above example) solve that issue? -- David FAURE, david@mandrakesoft.com, faure@kde.org http://people.mandrakesoft.com/~david/, http://www.konqueror.org/ KDE, Making The Future of Computing Available Today