Tuesday, 15 March 2011

C/C++ The purpose of static const local variable -



C/C++ The purpose of static const local variable -

in c , c++, advantage of making local const variable static? assuming initialization not utilize other variables, there difference between preserving value between calls, , setting same constant value each call?

could valid c compiler ignore static?

in c++, avoids construction/destruction between calls, there other benefit?

it doesn't take stack-space may benefit if have like:

static const double table[fairly_large_number] = { .... };

obviously, cost of construction can substantial plenty if function called lot, there's value in constructing object once.

c++ c static

No comments:

Post a Comment