Pointer to a class member
negerns
negerns2000 at gmail.com
Mon Aug 20 13:02:47 PDT 2007
0ffh wrote:
>
> 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();
> }
How do I display the value of a._name using the variable *p?
--
negerns
More information about the Digitalmars-d-learn
mailing list