[C++-sig] RE: Passing default argument

Goudar Basavaraj (IFIN DC SMS) Basavaraj.Goudar at infineon.com
Wed Nov 5 10:08:45 CET 2003


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