Calling private base methods

Duncan Booth duncan.booth at invalid.invalid
Fri Apr 13 09:39:11 CEST 2007

"Dan Bishop" <danb_83 at> wrote:

> I have a job as a C++ programmer and once tried this trick in order to
> get at a private member function I needed.  Didn't work: Apparently, VC
> ++ includes the access level in its name mangling, so you get linker
> errors.
I don't have a copy of VC to hand to test, but I might have tried something 
along these lines:

somheader contains:

class Whatever {
      void ohnoyoudont(int);

My C file:

#define ohnoyoudont blah(){};public: \
inline void sneak(int x){this.ohnoyoudont(x);};private:void ohnoyoudont
#include <someheader>
#undef ohnoyoudont

Whatever foo = new Whatever();
int ohyesido = 42;

I don't think injecting another couple of non-virtual methods into the 
class ought to break anything.

More information about the Python-list mailing list