Hi,
On Thu, 2004-09-02 at 16:41, shailesh kumar wrote:
> But what if the function and the functor creation is in the same class .
> I thought member function of the same class where functor creation is done
> will not require TypedMethod functor creation because we dont need an object
> to call a function in the same class. It should be same as when the function
> doesnt belong to any class where also we dont need any object .
> In the traverse sample , the function for the TypeMethod functor is in a
> different class.
> Have I understood it wrong ?
slightly, first, you need an object to call a member function, always,
no exceptions. The trick is if you are within another member function
the compiler is clever enough to figure out which object to use and
basically translates
void FOO::foo(void)
{
bar();
}
to
void FOO::foo(void)
{
this->bar();
}
implicitly (given that the name lookup resolves bar to be the
member function of FOO)
In terms of signature (as for the other example) static member or non-
member function have a different signature from member function,
static non-members have the following signature :
Action::ResultE (*)(NodePtr &);
whereas as a similar member function looks like
Action::ResultE (FOO::*)(NodePtr &);
and as signatures translate to types they also have different types,
that's why you get the 'can not convert' error message.
Second, similar in order to call myclass::enterSetVisible during the
execution of traverse you need an object to call this function on, hence
you have to use a functor that is able to retrieve an object on which
enterSetVisible will be called. So if you really want to use a member
function in this case you need to use the TypedStoredObject version,
which stores an object of type myclass an later uses it to call the
member function.
But even than your example will not work, as discussed in the other
mail, as your callback function signature is not compatible with what
traverse expects.
regards,
gerrit
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users