im having trouble getting the syntax right for this situation, ive searched everywhere and all the instructions of found im having trouble relating to what im trying to achieve.
Expand|Select|Wrap|Line Numbers
- class Foo {
- public:
- void blah(void);
- void memFunc(ptr* arg);
- list<ptr*> myList;
- };
- void Foo::blah(void) {
- for_each(myList.begin(), myList.end(), &Foo::memFunc);
- }
- void Foo::memFunc(ptr* arg) {
- //do stuff with arg and this
- }
but i dont know how to tell the compiler that i want the instance that is having blah called to be the instance that applies its memFunc. i couldnt get "this" to work and i was crashing the compiler with some of my attempts hehe
currently it just wont compile with the error message:
c:\program files\microsoft visual studio 8\vc\include\algorithm(29) : error C2064: term does not evaluate to a function taking 1 arguments
source.cpp(##) : see reference to function template instantiation '_Fn1 std::for_each<std::list<_Ty>::_Iterator<_Secure_va lidation>,void(__thiscall Foo::* )(ptr *)>(_InIt,_InIt,_Fn1)' being compiled
with
[
_Fn1=void (__thiscall Foo::* )(ptr *),
_Ty=ptr *,
_Secure_validation=true,
_InIt=std::list<ptr *>::_Iterator<true>
]
Windows, Visual C++ 2005 Express
thanks