NH>> switch (foo) {
NH>> case 1 :
NH>> int bar = 2;
NH>> break;
NH>> case 2 :
NH>> int bar = 3;
NH>> break;
NH>> }
DM> What are the compiler errors? IIRC, without jumping around to my
DM> compilers,
DM> I believe you'd get something along the lines of jumping over the
DM> initialization of bar. If you'd rename them to bar1 and bar2, you'd
DM> notice
DM> that your case 2 jumps past the initialization of bar1. That's because
DM> switch is basically a glorified goto - and bar1 is still in scope at
case
DM> 2.
in C/C++, lack of initialization is not an error. the error is that
there are two identical variable names.
matju
--- Terminate 4.00/Pro
---------------
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)
|