Re: Something like a final method
On Mar 22, 6:34 pm, litb <litb...@googlemail.com> wrote:
On 22 Mrz., 12:52, James Kanze <james.ka...@gmail.com> wrote:
Right pattern, but you've inverted the actions:
class Interface
{
public:
int getStatus() const
{
return doGetStatus() ;
}
private:
virtual int doGetStatus() const = 0 ;
} ;
class AbstractBase : public Interface
{
public:
int getStatus() const
{
return currentStatus ;
}
private:
virtual int doGetStatus() const
{
return getStatus() ;
}
private:
int myStatus ;
} ;
However i don't think that the inversion found in the derived
class is all that standard?
It's documented in Barton and Nackman. IMHO, the Barton and
Nackman is one book that everyone should read; although dated
(no namespaces, <iostream.h>, etc.), it covers a number of
points that I've not seen discussed elsewhere. But everytime I
mention a pattern from Barton and Nackman, everyone seems
surprised by it.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34