# Registering object properties

Class member variables can be registered so that they can be directly accessed by the script without the need for any method calls.

    struct MyStruct
    {
      int a;
    };

    r = engine->RegisterObjectProperty("mytype", "int a", offsetof(MyStruct,a)); assert( r >= 0 );

offsetof() is a macro declared in stddef.h header file.

It is also possible to expose properties through property accessors, which are a pair of class methods with prefixes get_ and set_ for getting and setting the property value. These methods should be registered with RegisterObjectMethod. This is especially useful when the offset of the property cannot be determined, or if the type of the property is not registered in the script and some translation must occur, i.e. from `char*` to `string`.