Learn to use pointers, then you can pass a pointer to the motor object to the function. Lots of stiuff out there on this, including tutorials, but the basics are:
The address of an object or variable is given by &varname, so calling a function with
passes a pointer to the variable.
The function declaration needs to be
that makes varname a pointer to a variable of type
Then to reference the methods of the object you use ->