Pointer to a class member
0ffh
spam at frankhirsch.net
Mon Aug 20 12:52:32 PDT 2007
like so?
module test;
import std.stdio;
class A {
char[] _name;
public this(char[] n) { _name = n; }
public char[]* get() { return (&_name); }
public void show() { writefln(_name); }
}
void main() {
auto a = new A("digitalmars");
// I wanted a variable here to point to A._name's value
// and manipulate it and expect the A._name's value to
// reflect that change. Something like:
char[]* p = a.get();
*p ~= ".com";
// and excpect a._name's value becomes "digitalmars.com"
a.show();
}
More information about the Digitalmars-d-learn
mailing list