[C++-sig] exposing a private member function?

Stefan Seefeld seefeld at sympatico.ca
Wed May 17 17:19:52 CEST 2006


Naceur Meskini wrote:
> Hi everybody,
> 
> the situation is :
> I have two classes, A and B defined like that:
> class A
> {
>     public:
>     insert();
>     ......
> }
> class B: public A
> {
>     pivate:
>     insert();
>     ......
> }
> and I want to expose both to python, is it possible to tell to boost 
> that the function insert of B will be private in python.

First of all, python doesn't have any notion of 'private'. The closest you
can get is prefixing the name under which you register it by '_' or even '__'.

Second, you can't expose a private method, since you'd need to dereference
it ('&B::insert'), which the private access-spec prohibits.

Third, I'm not sure what you mean by 'expose both'. They are simply
two distinct methods of two different classes.
To have them both available in the same class, they need to have different
signatures, and you have to make sure that the second doesn't hide the first,
for example by means of a 'using A::insert' declaration within B.

Regards,
		Stefan



More information about the Cplusplus-sig mailing list