A question on member functions in a class using lambda expression? Can anyone with kindness help me?

I am using Dev-C++ 4.9.8.0,with lambda expression: ...................... class A{ ............. int result; double function2(const int& n) ......................... double function3(const int& Q,const int& N) ...................... double function1(const int& q, int& n){ double result=0.0; int loopvalue=0, totaltime=n; n%=q; ++thenumbern; ( for_loop(var(loopvalue)=0,var(loopvalue)<=var(totaltime),++var(loopvalue), var(result)+=( bind(&A::function2,_2)*bind(&A::function3,_1,_2))))(q,n); return result; } But the complier told me that: ............................... \boost\lambda\detail\select_functions.hpp instantiated from `Arg::sig<boost::tuples::tuple<A&,................. instantiated from `RET boost::lambda::lambda_functor_base<boost::lambda::forloop_action, Args>::call(A&, B&, C.................... \boost\lambda\detail\lambda_functors.hpp instantiated from `T::sig<boost::tuples::tuple<A&, B&, boost::tuples::null_type, boost::tuples::null_type, ............... instantiated from here By the way, is the result in var(result) the double result in function1 or the int result in class A? Can any one with kindness help me?

2009/7/21 fmingu <fmingu@163.com>
....................... double function1(const int& q, int& n){ double result=0.0; int loopvalue=0, totaltime=n; n%=q; ++thenumbern; ( for_loop(var(loopvalue)=0,var(loopvalue)<=var(totaltime),++var(loopvalue), var(result)+=( bind(&A::function2,_2)*bind(&A::function3,_1,_2))))(q,n); return result; }
There is advanced lambda syntax that might simplify your function. This technique is secret though, so don't share it with anyone. double function1(const int& q, int& n) { double result=0.0; int totaltime=n; n%=q; ++thenumbern; // Now use the advanced lambda syntax. for (int loopvalue=0; loopvalue<=totaltime; ++loopvalue) result += function2(n)*function3(q,n); return result; } Roman Perepelitsa.

Oh.Please do not play joke on me. I am doing my work seriously. I really want the answer on lambda expression in order to know lambda expression further. Can any one with kindness help me? I am using Dev-C++ 4.9.8.0,with lambda expression: ..................... class A{ ............ int result; double function2(const int& n) ........................ double function3(const int& Q,const int& N) ..................... double function1(const int& q, int& n){ double result=0.0; int loopvalue=0, totaltime=n; n%=q; ++thenumbern; ( for_loop(var(loopvalue)=0,var(loopvalue)<=var(totaltime),++var(loopvalue), var(result)+=( bind(&A::function2,_2)*bind(&A::function3,_1,_2))))(q,n); return result; } But the complier told me that: .............................. \boost\lambda\detail\select_functions.hpp instantiated from `Arg::sig<boost::tuples::tuple<A&,................. instantiated from `RET boost::lambda::lambda_functor_base<boost::lambda::forloop_action, Args>::call(A&, B&, C.................... \boost\lambda\detail\lambda_functors.hpp instantiated from `T::sig<boost::tuples::tuple<A&, B&, boost::tuples::null_type, boost::tuples::null_type, ............... instantiated from here By the way, is the result in var(result) the double result in function1 or the int result in class A? Can any one with kindness help me?

2009/7/21 fmingu <fmingu@163.com>
Oh.Please do not play joke on me. I am doing my work seriously. I really want the answer on lambda expression in order to know lambda expression further. Can any one with kindness help me?
I am using Dev-C++ 4.9.8.0,with lambda expression:
..................... class A{ ............. int result; double function2(const int& n) ......................... double function3(const int& Q,const int& N) ...................... double function1(const int& q, int& n){ double result=0.0; int loopvalue=0, totaltime=n; n%=q; ++thenumbern; ( for_loop(var(loopvalue)=0,var(loopvalue)<=var(totaltime),++var(loopvalue), var(result)+=( bind(&A::function2,_2)*bind(&A::function3,_1,_2))))(q,n); return result; } But the complier told me that: ............................... \boost\lambda\detail\select_functions.hpp instantiated from `Arg::sig<boost::tuples::tuple<A&,................. instantiated from `RET boost::lambda::lambda_functor_base<boost::lambda::forloop_action, Args>::call(A&, B&, C.................... \boost\lambda\detail\lambda_functors.hpp instantiated from `T::sig<boost::tuples::tuple<A&, B&, boost::tuples::null_type, boost::tuples::null_type, ............... instantiated from here
By the way, is the result in var(result) the double result in function1 or the int result in class A? Can any one with kindness help me?
________________________________ 网易YEAH.NET免费邮箱:您的终身免费邮箱 _______________________________________________
You've forgotten that member functions need an object reference...change bind(&A::function2,_2) to bind(&A::function2,this,_2) and bind(&A::function3,_1,_2) to bind(&A::function3,this,_1,_2) HOWEVER - as Roman was alluding - just because you CAN do something (like this loop) in lambda doesn't mean it's a good idea to... Stuart Dootson
participants (3)
-
fmingu
-
Roman Perepelitsa
-
Stuart Dootson