Thanks everyone. I solved my question by adding a special method.
I'm writing a wrapper for a C library. I would like to preserve the '+=' and
'-=' operators for structure members. Maybe you can use a template or a macro?
Thank you. This works well if the "m" is the right type. But what if the
private “m” is of a different type and needs conversion?
type
Obj = object
m: cint
proc `m`*(o: var Obj): var int = int(o.m) # Error
Run
I recently started learning the Nim language and ran into a problem. I can
define operators to get and set a private member of an object, but I need the
"+=" operator. How to properly define the "+=" operator for a private member of
an object?
type
Obj* = object
m: in