Re: rs_settings
Posted by
dxli on
Aug 24, 2015; 2:18am
URL: https://forum.librecad.org/rs-settings-tp5712040p5712043.html
the *ok pointer is passed by the function caller.
this way, the function can return two values, the part by return, and the boolean by *ok. If the caller needs the ret part only, the pointer is set to nullptr, and the *ok part would be ignored.
Another similar example, to find the nearest Endpoints in rs_entitycontainer:
RS_Vector RS_EntityContainer::getNearestEndpoint(const RS_Vector& coord, double* dist = nullptr ) const;
if the caller wants to find the the nearest endpoint of entities, and the actual distance to it, call the function with two parameters, with the second one a valid pointer to a double.
If the caller only wants the nearest endpoint, and doesn't care about the distance, supply a nullptr to as the second parameter (the default value).
ravas wrote
I don't understand what happens next, the purpose of setting "ok".
"ok" is not used again in the function.