Boost logo

Boost :

From: VesselinPeev_at_[hidden]
Date: 2001-07-29 16:23:39

Dear Sirs,

I have come across the following problem:

class A {
                A(int i);
                virtual Func();

{ printf("\nwrong (default) A constructor invoked"); }

A::A(int i)
{ printf("\nproper A constructor invoked"); }

{ printf("\nA function invoked"); }

class B : public A {
                B(int i);

{ printf("\nB function invoked"); }

B::B() { printf("\nwrong (default) B constructor invoked"); }

B::B(int i) : A(i) { printf("\nproper B constructor invoked"); }


python::class_builder<A> aclass(qsm, "aclass");
python::class_builder<B> bclass(qsm, "bclass");


From Python script:

b = bclass(999)

Output (surprisingly for me):

wrong (default) A constructor invoked
wrong (default) B constructor invoked

Why is this happening? I am also forced to define the default
constructors without arguments, othewise I get compile errors.

One last question. Is there a good technique for specifying default
arguments of C++ functions called from Python in this way? Perhaps
through metaprogramming?

I am using Visual C++ SP6 with Win2K SP2.

Thank you in advance for you help.

Boost list run by bdawes at, gregod at, cpdaniel at, john at