John Matthews wrote: > --- In [email protected], John Gaughan <[EMAIL PROTECTED]> wrote: > >> You can also separate the declaration and assignment of the variable. >> For example, declare the variable outside that scope in a place such as >> the start of the method or block, and assign it inside the case. >> > > I could, but the variable is only used inside the case, so it makes > sense to keep its scope to within the case only. Another approach > would be to put the case code and variable inside a function and call > that instead. >
Disclaimer: I have not looked this up in the standard before arguing this point so I could be wrong. Yes, I have official copies of both the C and C++ standards. Is the scope not the switch, rather than the case? I thought cases were just labels, and the switch was the scope. -- John Gaughan
