On Mar 18, 10:57 am, Jerry Coffin <jcof...@taeus.comwrote:
Quote:
In article <7864a589-19a7-458d-99cd-
2611d772e...@x41g2000hsb.googlegroups.com>, zhang.xi...@gmail.com
says...
>
>
>
Quote:
What if I want the following:
>
>
Quote:
// v is loaded by push_back()
>
Quote:
switch( v.size() ) {
case 2:
//do something
>
Quote:
case 4:
//somehow delete two element
//and then do the same thing as in case 2
>
Quote:
case 6:
//somehow delete two element
//and then do the same thing as in case 4
>
>
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.
Quote:
>
--
Later,
Jerry.
>
The universe is a figment of its own imagination.