www.digitalmars.com         C & C++   DMDScript  

D - Syntax problem

reply "Gary" <gedumer bcpl.net> writes:
I started putting together some classes and ran into a problem. I planned on
using the format specified in the docs as follows:

     class Abc
     { int myprop;
      void property(int newproperty) { myprop = newproperty; } // set'er
      int property() { return myprop; } // get'er
     }

which is used as:
     Abc a;
     a.property = 3;  // equivalent to a.property(3)
     int x = a.property;  // equivalent to int x = a.property()

This results in the following error:

    test.d(27): cannot implicitly convert int to void(int newproperty)

which refers to the following line:

     a.property = 3;  // equivalent to a.property(3)

BTW... it works when I specify a.property(3), but the docs specify the other
is prefered, but it doesn't work.

Another question I have pertains to getting input from the keyboard. I tried
using:

    char c = getc();

But that didn't work... so what statement do I use?

Thanks... Gary.
Mar 06 2003
parent Patrick Down <Patrick_member pathlink.com> writes:
Properties are not implemented yet as well as the vector
syntax.

Walter really needs to note this in the documentation.

In article <b484ba$hfr$1 digitaldaemon.com>, Gary says...
I started putting together some classes and ran into a problem. I planned on
using the format specified in the docs as follows:

     class Abc
     { int myprop;
      void property(int newproperty) { myprop = newproperty; } // set'er
      int property() { return myprop; } // get'er
     }

which is used as:
     Abc a;
     a.property = 3;  // equivalent to a.property(3)
     int x = a.property;  // equivalent to int x = a.property()

This results in the following error:

    test.d(27): cannot implicitly convert int to void(int newproperty)

which refers to the following line:

     a.property = 3;  // equivalent to a.property(3)

BTW... it works when I specify a.property(3), but the docs specify the other
is prefered, but it doesn't work.

Another question I have pertains to getting input from the keyboard. I tried
using:

    char c = getc();

But that didn't work... so what statement do I use?

Thanks... Gary.
Mar 06 2003