Just talking to a colleague at work how to declare variables. For me, I have already decided which style I prefer, but maybe I'm wrong.
Style C is the whole variable at the beginning of the function. If you want to know the data type of a variable, just look at the beginning of the function.
bool Foo() { PARAM* pParam = NULL; bool rc; while (true) { rc = GetParam(pParam); ... do something with pParam } }
The "C ++" style is to declare variables as local as possible.
bool Foo() { while (true) { PARAM* pParam = NULL; bool rc = GetParam(pParam); ... do something with pParam } }
What do you prefer?
Update The question is about POD variables.
source share