|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> wrote:
> class Thing {
> static public int pdq(float y) { ... }
> public abc(float z) { return (int) (z*this.stuff); }
> int stuff;
> Thing() { stuff = 28; }
> }
> Thing o = new Thing();
> delegate int xyz(float x);
> xyz = Thing.pdq;
> xyz += o.abc;
> xyz(27.3); // I think this will return the result of calling o.abc(27.3)
> Pretty handy.
What if you want to call the function (through the pointer) for different
objects? I mean like you would write in C++:
Object obj1, obj2;
obj1.*funcPtr(param);
obj2.*funcPtr(param);
The same member function is called, but for different objects. (Thus if
the function in question eg. changes the state of the object, it happens
to the specified object.)
Curiously, you can even have pointers-to-member-variables in C++, and you
can then dereference the pointer on a per-object basis. That gets pretty
confusing pretty quick.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |