[C++-sig] Re: Default Argument passing to Constructor

Nikolay Mladenov nickm at sitius.com
Thu Nov 6 15:26:14 CET 2003


See the thread from monday: "Passing default argument"

Nikolay

John Slater wrote:
> 
> Hi,
> 
> I am stuck badly with this problem.
> 
> In class base I have an overloaded constructor with default arguments.
>   class base
>   {
>        public:
>             base(int k,int i=0,int x=0)
>             {
>             }
>    };
> 
> 
> Which is exposed to pyhton by boost as follows.
> 
>  .def(init<int,optional<int,int>
> >(args("k","i","x"),"_init_docstring"))
> 
> From python I import this.
> 
> call the constructor
> 
> >>>obj.base(1) //Success
> >>>obj.base(k=1, i=2) //Success
> >>>obj.base(k=1, i=2, x=2) //Success
> >>>obj.base(k=1, x=2) //Failure...
> 
> Is it I have to pass all preceding arguments, or am I missing
> something..
> 
> Please help me out
> 
> 
> Thanks & Regards,
> John Slater
> 
> 
> 
> 
> 
> ----------------------------------------------------------------------
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard
> 
>     ---------------------------------------------------------------
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig





More information about the Cplusplus-sig mailing list