What is the standard way to name a temp variable in the local function? let me give you an illustration of what I am doing. I get a pointer to a structure, so I want store one o
I'd say try to find something that most specifically describes the purpose of the variable and at the same time distinguishes it from any other variables used in that function.
So, assuming that "d" actually represents some name that already describes the meaning of your variable, then I'd go with something like cached_d
or copied_d
. That way you can have more (cached_a
, cached_b
, cached_c
, etc) without confusion among them.
And then I would further suggest including a comment that states specifically why you made that local copy. Perhaps something like:
double cached_d = f->m_d; // cached to avoid further de-referencing
That way anyone looking at that code in the future should have no problems figuring out what you're doing and why.