Pointer to member variable again

ws wisiong at gmail.com
Mon Jul 28 19:45:36 PDT 2008


Suppose i have the following:

int function() fp;
int *ptr;
class Cls
{
 int k;
 int foo()  {  return 0;  }
}

void main()
{
 fp = &Cls.foo;

 Cls c = new Cls;
 ptr = &c.k;  // <-- why always need a new instance?
}

As compared to delegate, is there no analogous way to specify this?

ptr = &Cls.k

Thanks!


More information about the Digitalmars-d-learn mailing list