On Mar 18, 10:57 am, Jerry Coffin <jcof...@taeus.comwrote:
In article <7864a589-19a7-458d-99cd-
2611d772e...@x41g2000hsb.googlegroups.com>, zhang.xi...@gmail.com
says...
What if I want the following:
vector<intv;
// v is loaded by push_back()
switch( v.size() ) {
case 2:
//do something
case 4:
//somehow delete two element
//and then do the same thing as in case 2
case 6:
//somehow delete two element
//and then do the same thing as in case 4
default:
//...
}
Correct -- continue works for loops by not switches. Fortunately you
don't need anything quite that difficult:
switch (v.size()) {
case 6:
// somehow delete two element (sic)
case 4:
// somehow delete two element
case 2:
// do something
}
If there isn't a break at the end of a block, execution will flow
through to the next block...
well, I gave a case not so tough, what if a case a little tougher?
vector<intv;
// v is loaded by push_back()
switch( v.size() ) {
case 2:
//do something
case 4:
//somehow delete two element
//and then do the same thing as in case 2
case 6:
//somehow delete *four* element
//and then do the same thing as in case 2
default:
//...
}
i.e. I want to go to case 2 both after I treat the case 4 and case 6.
>
--
Later,
Jerry.
The universe is a figment of its own imagination.