Posts

Showing posts from January 24, 2019

How to create externally unmodifiable variable?

Image
4 1 I'm developing simple simulation library and came across problem, where I have simulation Time variable, which shouldn't be modifiable by API user (programmer) at any circumstances (just provide information about simulation time), but should be modifiable by simulation library, so it cannot be constant. This is what i came up with yet but it seems a little bit tricky to me double simTime; // Internal time, modified by library const double& Time = simTime; // Time info provided for programmer in API Is there any better approach for this? c++ code-design share | improve this question edited Dec 31 '18 at 16:08