www.digitalmars.com         C & C++   DMDScript  

D - Bug? Property Access

reply "Paul Stadler" <paul_stadler hotmail.com> writes:
Hello all.  I'm trying to access some properties instead of using them
get/set style.  This is indicated in the "Classes" section of the
documentation as being possible, so i decided to use the code almost as it
was there.  Unfortunately, it didn't seem to compile.  Does anyone have any
idea if I've done it incorrectly... or if it's not supported yet?  I've put
the code and the command line below.

Cheers,
Paul

class ABC {
public:
 int myprop;
 int property() { return myprop; }
 void property(int m) { myprop = m; }
}

int main(char[][] argv) {
 ABC a;
 a.property = 5;
 int x = a.property;
 return 0;
}

--returns--
pstadler MOBILE ~/t1
$ dmd t1.d
t1.d(12): cannot implicitly convert int to int()
Jul 21 2003
parent Tim Gift <Tim_member pathlink.com> writes:
I believe that property get/set has not been implemented yet in the compiler.
There's a comment about it on the "General" section of the compiler download
page (as well as in some previous posts).

It's a feature I'd like to use myself, but I haven't seen anything posted about
when it might be implemented.

In article <bfhf92$2lnl$1 digitaldaemon.com>, Paul Stadler says...
Hello all.  I'm trying to access some properties instead of using them
get/set style.  This is indicated in the "Classes" section of the
documentation as being possible, so i decided to use the code almost as it
was there.  Unfortunately, it didn't seem to compile.  Does anyone have any
idea if I've done it incorrectly... or if it's not supported yet?  I've put
the code and the command line below.

Cheers,
Paul

class ABC {
public:
 int myprop;
 int property() { return myprop; }
 void property(int m) { myprop = m; }
}

int main(char[][] argv) {
 ABC a;
 a.property = 5;
 int x = a.property;
 return 0;
}

--returns--
pstadler MOBILE ~/t1
$ dmd t1.d
t1.d(12): cannot implicitly convert int to int()

Jul 21 2003