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

John Slater john_slater33 at yahoo.com
Thu Nov 6 06:37:21 CET 2003


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20031105/c56072e7/attachment.htm>


More information about the Cplusplus-sig mailing list