[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()
[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()
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();
>
[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
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
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