MichaelB.
7/28/2018 - 10:09 AM

How to self-reference

When referring to components of a class inside the class itself we normally just use the component name. Where we have some ambiguity like in our example we can use the self-reference syntax to refer to an objects attributes, methods and the object itself. This makes use of the local reference variable me that refers to the object. Don't call your constructors or any other parameters the same name as attributes within your class. That causes ambiguity.

me->attribute_name

  METHOD constructor.                   "Instance Constructor
*    make = make.
*    model = model.
*    numseats = numseats.
*    maxspeed = maxspeed.
    me->make = make.
    me->model = model.
    me->numseats = numseats.
    me->maxspeed = maxspeed.
    numofcars = numofcars + 1.          "Increment the car counter Static Variable
  ENDMETHOD.