[C++-sig] Re: Passing default argument
Nikolay Mladenov
nickm at sitius.com
Wed Nov 5 15:14:40 CET 2003
Basavaraj,
arg and args are declared in one header file (in namespace
boost::python). So if you have args declared
you should have arg declared as well, provided that your BPL version is
recent(CVS).
Nikolay
"Goudar Basavaraj (IFIN DC SMS)" wrote:
>
> Hi Nikolay,
>
> Thanks for the info. I tried this but am getting error saying
> "arg undeclared". I tried including few headers but could not
> resolve the problem.
> What could be the solution.
>
> Thanks & Regards,
> Basavaraj
>
> BOOST_PYTHON_MODULE(overload)
> {
> class_<A>("A")
> .def("F",&A::f, (arg("a")=2,arg("b")=4,arg("c")=10,arg("d")=4) ))
> ;
> }
>
> > -----Original Message-----
> > From: Goudar Basavaraj (IFIN DC SMS)
> > Sent: Monday, November 03, 2003 5:11 PM
> > To: 'c++-sig at python.org'
> > Subject: Passing default argument
> >
> > Hi,
> >
> > I am facing a problem in passing default parameters to this program.
> >
> > class A
> > {
> > public:
> > A(){}
> > void f(int a=2,int b=4,int c=10,int d=4)
> > {
> > printf("HI am here\n");
> > }
> > };
> > BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(F1,A::f,0,4)
> >
> > BOOST_PYTHON_MODULE(overload)
> > {
> > class_<A>("A")
> > .def("F",&A::f,F1(args("a","b","c","d")))
> > ;
> > }
> >
> > I call the overloaded method from python by passing
> > >>>name=overload.A()
> > >>>name.F(a=0) //This works fine
> > >>>name.F(a=0,b=1) //This works fine
> > >>>name.F(b=1) //Fails.
> > bad argument type for built in operation
> >
> >
> > I am not able to figure out whether this is the property of boost or
> > I have to do something else.
> >
> > Please let me know................
> >
> > Thanks & Regards,
> > Basavaraj
More information about the Cplusplus-sig
mailing list