Pointer to member variable again

Manfred_Nowak svv1999 at hotmail.com
Mon Jul 28 21:36:20 PDT 2008


ws wrote:

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

Because `k' does not exist without an instantiation of the class.

If you want `k' to be the same variable for every instance of the class 
you have to declare it as `static':

  static int k;

-manfred 
-- 
Maybe some knowledge of some types of disagreeing and their relation 
can turn out to be useful:
http://blog.createdebate.com/2008/04/07/writing-strong-arguments/


More information about the Digitalmars-d-learn mailing list