www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - from C++ to D...

reply Regan Heath <regan netwin.co.nz> writes:
This is a C++ struct..

struct bob
{
	void check1(void *blert) {
		..etc..
	}

	void (bob::*check2(void *blart))(void *) {
		..etc..
		return check1;
	}
};

how do I write that in D?

It is a function that takes a void * and returns a function that takes a 
void *

I know I use delegate, but how. :)

Thanks in advance.

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 13 2004
parent reply Sam McCall <tunah.d tunah.net> writes:
Regan Heath wrote:

 This is a C++ struct..
 
 struct bob
 {
     void check1(void *blert) {
         ..etc..
     }
 
     void (bob::*check2(void *blart))(void *) {
         ..etc..
         return check1;
     }
 };
 
 how do I write that in D?
struct bob { void check1(void* blert) { } void delegate(void *) check2(void* blart) { return &check1; } } I think that's right... much easier on the eyes :-) Sam
Jun 13 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Mon, 14 Jun 2004 17:49:40 +1200, Sam McCall <tunah.d tunah.net> wrote:
 Regan Heath wrote:

 This is a C++ struct..

 struct bob
 {
     void check1(void *blert) {
         ..etc..
     }

     void (bob::*check2(void *blart))(void *) {
         ..etc..
         return check1;
     }
 };

 how do I write that in D?
struct bob { void check1(void* blert) { } void delegate(void *) check2(void* blart) { return &check1; } } I think that's right... much easier on the eyes :-)
Thanks. :) I should have worked it out, for some reason I just couldn't my brain is still programmed for C/C++ I'm afraid. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 13 2004
parent reply "Walter" <newshound digitalmars.com> writes:
"Regan Heath" <regan netwin.co.nz> wrote in message
news:opr9kmlcn75a2sq9 digitalmars.com...
 I should have worked it out, for some reason I just couldn't my brain is
 still programmed for C/C++ I'm afraid.
At some point, you'll find you can't go back to C++ <g>.
Jun 14 2004
parent "Matthew" <admin stlsoft.dot.dot.dot.dot.org> writes:
"Walter" <newshound digitalmars.com> wrote in message
news:cajj1r$2sqp$1 digitaldaemon.com...
 "Regan Heath" <regan netwin.co.nz> wrote in message
 news:opr9kmlcn75a2sq9 digitalmars.com...
 I should have worked it out, for some reason I just couldn't my brain is
 still programmed for C/C++ I'm afraid.
At some point, you'll find you can't go back to C++ <g>.
When's that then? <g> I have to say, though, that I've been inspired by D to introduce various things into C++ libraries to give the same functionality.
Jun 14 2004