Newbie question

David L. Davis SpottedTiger at yahoo.com
Tue Nov 28 13:52:42 PST 2006


Hi Dune,


    You needed the following line change "Foo f = new Foo;" since
a class is an object, you needed to create it first before you
using it.

class Foo {
  public:
  int data() { return m_data; }                  // read property
  int data(int value) { return m_data = value; } // write property

  private:
  int m_data;
}

void main() {
  Foo f = new Foo;
  f.data = 3; // same as f.data(3);
  printf ("%d", f.data + 3); // same as return f.data() + 3;
}

David L



More information about the Digitalmars-d-learn mailing list