gww@bbn.com (George Williams) (08/16/89)
7) What is the scope of (and when do destructors get called on:)
switch(i) {
case 1:
String q(10);
case 2:
String j(10);
default:
String k(10);
}
jenings@hpfclp.SDE.HP.COM (Byron T. Jenings Jr.) (09/06/89)
|/ hpfclp:comp.lang.c++ / gww@bbn.com (George Williams) / 12:18 pm Aug 15, 1989 / |7) What is the scope of (and when do destructors get called on:) | switch(i) { | case 1: | String q(10); | case 2: | String j(10); | default: | String k(10); | } The easiest way to think of this is that the labels in a case statement are just like any other C label, and {} blocks are the same as any other block. You can think of the "switch" as expanding into a bunch of "if (i == XXX) then goto XXX;" statements. This means that the scope of each variable extends from the declaration down to the closing curly, as usual.