Re: strategy pattern and non-public virtual functions

2006-06-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi python experts > > In C++ I can do something like this: > class Base { > public: > void f() { this->f_(); } > private: > virtual void f_() = 0; > }; > > class Derived : public Base { > private: > void f_() { // Do something } > }; > > int main()

Re: strategy pattern and non-public virtual functions

2006-06-05 Thread John J. Lee
[EMAIL PROTECTED] writes: > Hi python experts > > In C++ I can do something like this: > class Base { > public: > void f() { this->f_(); } > private: > virtual void f_() = 0; > }; > > class Derived : public Base { > private: > void f_() { // Do something } > }; > > int main()

Re: strategy pattern and non-public virtual functions

2006-06-05 Thread Maric Michaud
Le Lundi 05 Juin 2006 16:07, [EMAIL PROTECTED] a écrit : > class Base { >   public: >     void f() { this->f_(); } >   private: >     virtual void f_() = 0; > }; > > class Derived : public Base { >   private: >     void f_() { // Do something } > }; > > int main() { >     Derived d; >     d.f(); >

Re: strategy pattern and non-public virtual functions

2006-06-05 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote: > Just translating this code to python won't work, due to the name > mangling of private functions: > class B(object): > def f(self): > self.__f() > > class D(B): > def __f(self): > pass > > d = D() > d.f() > > So my questions are: > 1. Is there a

Re: strategy pattern and non-public virtual functions

2006-06-05 Thread Duncan Booth
wrote: > The users of the derived classes are unable to bypass this base class > function. Just to be clear, the users of the derived C++ classes *are* able to bypass the base class function and call f_() directly, they just have to be prepared to twist the rules somewhat. I know: I've been in

strategy pattern and non-public virtual functions

2006-06-05 Thread pythoncurious
Hi python experts In C++ I can do something like this: class Base { public: void f() { this->f_(); } private: virtual void f_() = 0; }; class Derived : public Base { private: void f_() { // Do something } }; int main() { Derived d; d.f(); } The point of this is that th