S
shaun roe
This may be a question of style:
Sometimes I need a little helper function (e.g. checkRange(val, lo, hi))
in my .cpp and have a habit of making these functions simple standalone
functions in the .cpp file instead of member functions, because they
don't access any member variables. My understanding is that the 'static'
keyword in this context restricts their scope to the .cpp file.
If I find I use the function a lot, I promote it to a fully fledged
standalone function in a standalone .h & .cpp file as usual.
2 questions:
a) Does this seem reasonable, or is it 'poor style'?
b) is my understanding of static correct? What if I do not declare the
function static, doesn't it have file scope anyway?
cheers
shaun
Sometimes I need a little helper function (e.g. checkRange(val, lo, hi))
in my .cpp and have a habit of making these functions simple standalone
functions in the .cpp file instead of member functions, because they
don't access any member variables. My understanding is that the 'static'
keyword in this context restricts their scope to the .cpp file.
If I find I use the function a lot, I promote it to a fully fledged
standalone function in a standalone .h & .cpp file as usual.
2 questions:
a) Does this seem reasonable, or is it 'poor style'?
b) is my understanding of static correct? What if I do not declare the
function static, doesn't it have file scope anyway?
cheers
shaun